Original link: http://www.verejava.com/?id=1699255231918
/* Note: 1. Variable naming does not allow repetition of 2. Naming rules for variables: a character, an underscore, a $, a number, and the beginning of the first letter must be a character, a slide line, or $ cannot be a number */public class testvariable{public static void Main (string[] args) {//Variable definition: A system-allocated chunk of memory used to store data in a//string type string: A character or kanji enclosed in double quotes ""//bottle Variable name//equals = Delegate assignment that means "mineral water" data is stored in a memory area named bottle. String bottle= "Mineral water"; Print output of the variable named Bottle Memory area to the console System.out.println (bottle); Modify the value of the variable to replace "juice" with the value of the bottle memory area bottle= "Juice"; SYSTEM.OUT.PRINTLN (bottle); Empties the variable, emptying the bottle memory data bottle= ""; SYSTEM.OUT.PRINTLN (bottle); Delete variable, assign value to null value delete variable, this time garbage collector GC if scan to//bottle variable will automatically reclaim allocated memory space bottle=null; SYSTEM.OUT.PRINTLN (bottle); Note://1. Variable names cannot be defined repeatedly, otherwise compilation cannot be bottle= "milk" through//string; SYSTEM.OUT.PRINTLN (bottle); The naming rules for variables: a character, an underscore, a $, a number, and the beginning of the first letter must be a character, the slide line or the $ cannot be a number//string 1a= "a"; SYSTEM.OUT.PRINTLN (1a); String $b = "B";System.out.println ($b); String _c= "C"; System.out.println (_c); }}
Original link: http://www.verejava.com/?id=1699255231918
Variables for the Java Foundation