MATLAB BUILDER JA 2 Guide de l'utilisateur Page 191

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 292
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 190
Using Class Methods
Inthecasewhereindex is of type int[],eachelementoftheindex vector
is an index along one dimension of the
MWCharArray object. The valid range
for any index is
1 <= index[i] <= N[i],whereN[i] isthesizeoftheith
dimension.
Exceptions
The set method throws the following exception:
IndexOutOfBoundsException
The specified index parameter is invalid.
Example Setting Values in a Character Array
Display a phrase stored in MWCharArray object A, change one of the characters,
and then display the modified phrase:
char[] chArray = {'G', 'a', 'r', 'y'};
MWCharArray A = new MWCharArray(chArray);
System.out.println(" I think " + A + " lives here." + "\n");
System.out.println("Changing the first character to M ...\n");
int[] index = {1, 1};
A.set(index, 'M');
System.out.println(" I think " + A + " lives here." + "\n");
When run, the example displays this output:
I think Gary lives here.
Changing the first character to M ...
I think Mary lives here.
4-115
Vue de la page 190
1 2 ... 186 187 188 189 190 191 192 193 194 195 196 ... 291 292

Commentaires sur ces manuels

Pas de commentaire