{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

Info icon This 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
Image of page 1

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

View Full Document Right 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
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 definition • This ONLY works if main() has a particular (required) format • A single class may only have ONE main() method 3
Image of page 3

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

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

{[ 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