Tag: RGS template does not validate Col friend in while RET
Arrays are supported in almost all programming languages. It is very dangerous to use arrays in C and C + +, because those arrays are just blocks of memory. If a program accesses an array other than its own block of memory, or uses memory (which is a general programming error) before initialization, it can have unpredictable consequences (note ②).
②: in C + +, you should try not to use arrays, in exchange for a more secure container in standard template libraries (templatelibrary).
One of the main design goals of Java is security. So many of the problems that plague programmers in C and C + + are not duplicated in Java. A Java can be guaranteed to be initialized and not accessible outside of its scope. Because the system automatically checks the scope, there is a certain price to pay: a small amount of memory overhead is incurred for each array and for checking the indexes during run time. But the result is a higher level of security and higher productivity. It is worthwhile to pay a little price for it. When an array of objects is created, an array of handles is actually created. And each handle is automatically initialized to a special value with its own keyword: null (NULL). Once Java sees NULL, it knows that the handle does not point to an object. Before you can use it formally, you must assign an object to each handle. If you try to use a handle that is still null, the problem is reported at run time. As a result, typical array errors are avoided in Java. You can also create an array of primary types. Similarly, the compiler can vouch for its initialization because it divides the memory of that array into 0. The array problem will be discussed in detail in a later section.
1 Packagecom.tomtest;2 3 4 ImportJava.util.*;5 Public classtomtest_49 {6 Public Static voidMain (String args[]) {7String s= "I am Geng.x.y,she is my girlfriend";8StringTokenizer fenxi=NewStringTokenizer (S, ","); 9 intNumber=Fenxi.counttokens ();Ten while(Fenxi.hasmoretokens ()) { OneString str=Fenxi.nexttoken (); A System.out.println (str); -System.out.println ("Still Left" +fenxi.counttokens () + "words"); - } theSystem.out.println ("s total word:" +number+ "); - } -}
An array of Java