04-the-main-method

04-the-main-method - The main() Method and Stand-alone Java...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
The main() Method and Stand-alone Java Programs CSE 114 (Computer Science I) SUNY at Stony Brook 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Announcements • Assignments • CodeLab 1 is due at 11:59 PM on Wednesday, February 20 • Homework 1 will be posted Tuesday evening • General Announcements • Labs begin tomorrow, Tuesday, February 19 • Midterm 1 is Thursday, March 6, in lab • A review session will be announced ASAP 2
Background image of page 2
The main() Method • Every Java program must have a method named main() • Note that this is PER-PROGRAM, not per class! • BlueJ lets us “cheat” by creating an invisible main() method for us • When you run a Java program, you (indirectly) call its main() method • “java myClass” tells the Java Virtual Machine to look for and call a method called main() inside the myClass class deFnition • This ONLY works if main() has a particular (required) format • A single class may only have ONE main() method 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The Format of main() • Every main() method has the same method header: public static void main (String [] args)
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

04-the-main-method - The main() Method and Stand-alone Java...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online