Outprintlnjava rules the formal arguments to the

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ember functions in C++) CPSC 324 ‐‐ Spring 2010 9 (Beginning) Anatomy of a Class •  Every Java application has to have: –  At least one class –  At least one main method (not per class, just in the app) public class MyFirstApp { public static void main(String args) { System.out.println(“Java Rules!”); } } The formal arguments to the method (an array of String objects called ‘args’) CPSC 324 ‐‐ Spring 2010 10 5 1/14/10 (Beginning) Anatomy of a Class •  Every Java application has to have: –  At least one class –  At least one main method (not per class, just in the app) public class MyFirstApp { public static void main(String args) { System.out.println(“Java Rules!”); } } The Java System class (can do lots of useful stuff) CPSC 324 ‐‐ Spring 2010 11 (Beginning) Anatomy of a Class •  Every Java application has to have: –  At least one class –  At least one main method (not per class, just in the app) public class MyFirstApp { public static void main(String args) { System.out.println(“Java Rules!”); } } A (static) field of the System class An object denoting the standard out (we’ll go over this later) CPSC 324 ‐‐ Spring 2010 12 6 1/14/10 (Beginning) Anatomy of a Class •  Every Java application has to have: –  At least one class –  At least one main method (not per class, just in the app) public class MyFirstApp { public static void main(String args) { System.out.println(“Java Rules!”); } } A method call on the out object (print a line to the terminal/console) CPSC 324 ‐‐ Spring 2010 13 (Beginning) Anatomy of a Class •  Every Java application has to have: –  At least one class –  At least one main method (not per class, just in the app) public class MyFirstApp { public static void main(String args) { System.out.println(“Java Rules!”); } } The actual argument to the method (the string to be printed in this case) CPSC 324 ‐‐ Spring 2010 14 7 1/14/10 (Beginning) Anatomy of a Class •  Every Java application has to have: –  At least one class –  At least one main method (not per class, just in the app) public class MyFirstApp { public static void main(String args) { System.out.println(“Java Rules!”); } Statements end in semicolons } CPSC 324 ‐‐ Spring 2010 15 (Beginning) Anatomy of a Class •  Every Java application has to have: –  At least one class –  At least one main method (not per class, just in the app) public class MyFirstApp { public static void main(String args) { System.out.println(“Java Rules!”); } } Braces define blocks of code CPSC 324 ‐‐ Spring 2010 16 8 1/14/10 (Beginning) Anatomy of a Class •  Every Java application has to have: –  At least one class –  At least one main method (not per class, just in the app) public class MyFirstApp { public static void main(String args) { System.out.println(“Java Rules!”); } } public means it can be accessed externally (the class and the met...
View Full Document

This document was uploaded on 03/18/2014 for the course CPSC 324 at Gonzaga.

Ask a homework question - tutors are online