In learning each new language, you will learn some basic knowledge of data types, operators, expressions, and so on, because the content is roughly the same, as long as the different points of grasping it can distinguish.
JAVA4 data types in Class 8
Type basic information
Key words |
Data type |
Number of bytes occupied |
Range of values |
Byte |
BYTE type |
1 bytes |
-128-127 |
Short |
Short-integer |
2 bytes |
-2 of 15 power-2 of 15 power-1 |
Int |
Integral type |
4 bytes |
-2 of 31 power-2 of 31 power-1 |
Long |
Long integer type |
8 bytes |
-2 of 63 power and 63 power-1 |
Float |
Single-precision floating-point type |
4 bytes |
System.out.println (float.max_value) system.out.println (float.min_value)   default value is: 0.0F |
Double |
Double-precision floating-point type |
8 bytes |
System.out.println (Double.max_value) System.out.println (Double.min_value) Default value is: 0.0d
|
Demo
Sometimes unsure about the type of some data, just write a little domo test it.
public class Testbyte {public static void main (string[] args) {System.out.println (byte.size); How many bits of//byte, returned as 8 System.out.println (byte.max_value);//byte maximum, returned as 127 System.out.println (byte.min_value);//byte minimum, returned as-128 System.out.println (Byte.type);//returns the type of byte, returned as a byte}}
Examples:
1, int i=1,j;t
2, float f1=0.1;floatf2=123;0.1 is a double type, and 123 is an int type. instead 0.1f or ( float ) 0.1
3, Long l1=12345678,l2=8888888888;12345678 can be installed, 10 8 not fit. instead 8888888888L
4, double d1=2e20,d2=124;t
5, byte b1=1,b2=2,b3=129; change to B3 less than or equal to 127 number
6, j=j+10;J only declares that it is not assigned, so it cannot be used.
7, I=1/10; result is 0
8, i=i*0.1;0.1 is a double type. Two number of operations, to be cast, instead (double) (i*0.1)
9, Char c1= ' A ', C2=125;a is a string type T
10. Byte B=b1-b2;b1 and B2 are converted to int type when doing the operation, so add the cast to (byte) (b1-b2)
11, Char c=c1+c2-1; this is the same as the above problem , the need to cast
12. Float F3=f1+f2;t
13, float f4=f1+f2*0.1; need to cast, change to (double) (f1+f2*0.1)
14, double d=d1*i+j; instead (double) (d1*i+j)
15, float f= (float) (D1*5+D2); T
the Java code and C + + code are likely to appear when the test is soft, and because the two languages are much the same, they are especially confusing .Java and C + +
Compile execution
Java can be executed multiple times due to the virtual machine mechanism implementation, C once programming, multiple compilations, and this also requires a high level of programming staff.
Developing the use of C + +: VC
Developing Java Usage:Eclipse, JCreator,jbuilder, NetBeans, etc.
Java code
<span style= "FONT-SIZE:18PX;" >public class test{public static void Main (String args[]) {//main function int j=1; for (i=0;i<5;i++) { j=i;}} } </span>
C + +
<span style= "FONT-SIZE:18PX;" >class date{public: date ();//constructor date (const date&);//copy constructor date strtodate (string);// Converts a string to date void SetDate (string);//Set Date void PrintDate ();//Print date private: int year; int month; int day; BOOL Pass; BOOL Checkformat (string);//validation date input format void validate ();//validation Date numeric validity bool Leapyear (int);//Leap year judgment};</span >
C + + desktop software development is very powerful, you can directly invoke Windows library functions.Java has a powerful class library function that can be used through import.
C + + Does the bottom-up development better than Java.
To figure out the difference between Java and C + +, you need to compare it a lot. I do not understand that there are clear children's shoes can help to talk about.
Java 4 Class 8 data types