Hello World program analysis (1).pdf - Hello World program...

This preview shows page 1 - 5 out of 17 pages.

Hello World program analysis (1) HelloWorld is the class name as well as program name . The file name must be the same as class name , plus the .java extension. ( HelloWorld.java ) The HelloWorld class is public , it is visible to other classes. main is a method 's name. The name main is special, it is the method that starts a program. The string " Hello World " is surrounded by " double quotes " public class HelloWorld { public static void main ( String[] args ) { System.out.println ( "Hello World" ); } }
Image of page 1

Subscribe to view the full document.

Basic (primitive) data types Type Description Default Size Value range boolean True or False false 1 bit false, true byte Very small integers 0 8 bits (-2 8 ) .. (2 8 - 1) -128 .. 127 short Small integers int Integers 0 32 bits (-2 31 ) .. (2 31 - 1) long Bigger integers 0 64 bits (-2 63 ) .. (2 63 - 1) float Real numbers 0.0 32 bits 1.424x10 -45 .. 3.4028x10 38 double More precise real numbers 0.0 64 bits 4.9406x10 -324 .. 1.7977x10 308 char UTF-16 character \u0000 16 bits \u0000 .. \uFFFF
Image of page 2
Declare & initialize a variable Initialize: give the variable an initial value. int age = 19; Data Type Space Semicolon Variable Name Initial Value
Image of page 3

Subscribe to view the full document.

Assignment statements means the shorter way (more on this later) x = 5 + 1; int x = 5; x = x + 1; x++;
Image of page 4
Image of page 5
  • Spring '19
  • Tran Doan Linh
  • len, 1 bit, 0 32 bits, 0 8 bits, 0 64 bits

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern