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

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 292
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 25
1 Getting Started
8 Access the component in a Java application. The sample application for this
example is in
MagicSquareExample\MagicDemoJavaApp\getmagic.java.
getmagic.java
/* getmagic.java
* This file is used as an example for the MATLAB
* Builder for Java product.
*
* Copyright 2001-2006 The MathWorks, Inc.
*/
/* Necessary package imports */
import com.mathworks.toolbox.javabuilder.*;
import magicsquare.*;
/*
* getmagic class computes a magic square of order N. The
* positive integer N is passed on the command line.
*/
class getmagic
{
public static void main(String[] args)
{
MWNumericArray n = null; /* Stores input value */
Object[] result = null; /* Stores the result */
magic theMagic = null; /* Stores magic class instance */
try
{
/* If no input, exit */
if (args.length == 0)
{
System.out.println("Error: must input a positive integer");
return;
}
/* Convert and print input value*/
n = new MWNumericArray(Double.valueOf(args[0]),MWClassID.DOUBLE);
1-18
Przeglądanie stron 25
1 2 ... 21 22 23 24 25 26 27 28 29 30 31 ... 291 292

Komentarze do niniejszej Instrukcji

Brak uwag