Java-defined data types

/ *
 The Java data types defined
 a variable according to the data type;
 basic data types;
 Integer: byte short int long
 float float double
 type char
 Boolean: boolean
 Reference data type
 classes (class)
 the interface (interface)
 array (Array)
Second, the position variables declared in the class
 member variable vs local variables
* /
class VariableTest1
{
 public static void main (String [] args)
 {
  // Integer: byte (1 byte = 8bit) short (2 bytes) int (4 bytes) long (8 bytes)
  
  // byte range of 127 ~ -128
  byte B1 = 12 is;
  byte B2 = -128;
  // B2 = 128; // not compiled by
  System.out.println (b1);
  System.out.println (B2);
  // declare variables must be long to "1" or "L" end
  // int type using normal integer variable is defined
  Short S1 = 128;
  int I1 = 1234;
  long L1 = 323232323L ;
  System.out.println (L1);
 
  . 2 // float float (4 byte) double (8 bytes)
  // float value represented with a decimal point
  // range of values represented by a float is larger than the long
  D1 = 123.3 Double;
  System.out.println (D1 +. 1);
  // the definitions float type variables, variables to "f" or "F" end
  F1 = 12.3F a float;
  System.out.println (F1);
  // normal floating-point variables define a double
  // 3 char char (1 = 2-byte character)
  // char type variable is defined using a pair of generally 'only internal write a character
  char C1 =' A ';
  C1 =' A ';
  // not compiled by
  // C1 = 'AB';
  System.out.println (C1);
  char = C2 '. 1';
  char = C3 'in';
  char C4 = 'mi fa';
  System.out.println (C2);
  the System. Out.println (C3);
  System.out.println (C4);
  // declare a character representation 1. 2. 3.Unicode escape character values to represent character constant
  char c5 = '\ n'; // newline
  c5 = '\ t'; // tabs
  System.out .print ( "Hello" + C5);
  System.out.println ( "World");
  
  char C6 = '\ u0043';
  System.out.println (C6);
 }
}

Guess you like

Origin www.cnblogs.com/xuezha/p/12075716.html