MATLAB BUILDER JA 2 Podręcznik Użytkownika Strona 105

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 292
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 104
Guidelines for Working with MWArray Classes
The a1, a2,anda3 arrays constructed all contain a 2-by-14 MATLAB char
array. The column count of the array is equal to the largest string length in
the input array. Rows with fewer characters than the maximum are
Null
padded. Arrays with larger numbers of dimensions are handled similarly.
This behavior parallels the way that
MWNumericArray and MWLogicalArray
handle jagged arrays.
Using Static Factory Methods for Constructing MWCharArrays
The following table lists the factory methods of MWCharArray.
Factor y Method Usage
newInstance(int[])
New char array. Values are initialized to Null.
newInstance(int[]
Object)
New char array. Values are initialized with
supported data.
These methods all return a new MWCharArray instance constructed from the
input informatio n . You can use these m ethods to construct a nd initialize
an array with supplied data, or to construct an a rray of a specified size and
initialize all values to zero. The main difference is that data is supplied to
the factory methods in one-dimensional arrays with the d ata arranged in
column-wise order. The input data array m ust be either a one-dimensional
array of
char, a one-dimensional array of java.lang.Character,orasingle
java.lang.String.
Rewriting Strings Using the newInstance Method. The following
examples rewrite the character string examples using
newInstance:
char[] x1 = {'A', ' ', 'S', 't', 'r', 'i', 'n', 'g'};
String x2 = "A String";
Character[] x3 =
{
new Character('A'),
new Character(' '),
new Character('S'),
new Character('t'),
new Character('r'),
new Character('i'),
new Character('n'),
4-29
Przeglądanie stron 104
1 2 ... 100 101 102 103 104 105 106 107 108 109 110 ... 291 292

Komentarze do niniejszej Instrukcji

Brak uwag