Java package class

xiaoxiao2021-03-06  103

Java has 8 basic data types. Because these data types are not something on the object hierarchy, they pass values ​​to the method without passing by reference. Creating or accessing a basic data type by means, can be encapsulated by the corresponding "package class".

EG:

INT data type package class integer.

Class cmdarg

{

Public static void main (string args [])

{

INT SUM = 0;

For (int Cut = 0; cut

Sum = Integer.Parseint (args [cut]);

System.out.println ("and" SUM);

}

}

Javac cmdarg.java

Java cmdarg 10 5 3

And for: 18

The PARSEIN () method in the Integer class performs a corresponding value of the corresponding value from the string.

10, 5, 3, store the string array args [], but does not incorporate the value to the code of the array, is it default? Is the default constructor of cmdarg? It feels not. This is some strange.

转载请注明原文地址:https://www.9cbs.com/read-100548.html

New Post(0)