MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Manual de usuario Pagina 181

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 408
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 180
Creating and Using Java Objects
5-11
class, class_name, with the argument list that matches x1,...,xn, and
returns a new object,
J.
J = javaObject('class_name',x1,...,xn);
For example, to construct and return a Java object of class java.lang.String,
you use
strObj = javaObject('java.lang.String','hello');
Using the javaObject function enables you to:
Use classes having names with more than 31 consecutive characters
Specify the class for an object at run-time, for example, as input from an
application user
The default MATLAB constructor syntax requires that no segment of the input
class name be longer than 31 characters. (A class name segment is any portion
of the class name before, between, or after a dot. For example, there are three
segments in class,
java.lang.String.) Any class name segment that exceeds
31 characters is truncated by MATLAB. In the rare case where you need to use
a class name of this length, you must use
javaObject to instantiate the class.
The
javaObject function also allows you to specify the Java class for the object
being constructed at run-time. In this situation, you call
javaObject with a
string variable in place of the class name argument.
class = 'java.lang.String';
text = 'hello';
strObj = javaObject(class, text);
In the usual case, when the class to instantiate is known at development time,
it is more convenient to use the MATLAB constructor syntax. For example, to
create a
java.lang.String object, you would use
strObj = java.lang.String('hello');
Vista de pagina 180
1 2 ... 176 177 178 179 180 181 182 183 184 185 186 ... 407 408

Comentarios a estos manuales

Sin comentarios