ex1 - Example 1: Output: Printing to the screen /* class...

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

View Full Document Right Arrow Icon
Example 1: Output: Printing to the screen /* class MyFirst Program * * Purpose: show how to display text to the screen in a Java program */ public class MyFirstProgram { /* main * * The main method begins any Java program * This method prints a message to the screen. */ public static void main(String[] args) { // print a message to the screen System.out.println("I am Professor Franklin."); System.out.println("I am here because I want to show you how intuitive and fun programming can be."); } // end of main } // end of class MyFirstProgram public – let others run this program class – tell the world that this is my program – it is an organization unit for a program MyFirstProgram – the name of my program. This must be in a file named MyFirstProgram.java static – make sure this function will always be in a place the operating system can find it void – this is a set of instructions, but it does not produce a result (all talk, no action) main – start here, no where else String[] args – a way to get information from the user when the program starts
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/27/2011 for the course CMPSC 5 taught by Professor Franklin during the Fall '09 term at UCSB.

Page1 / 2

ex1 - Example 1: Output: Printing to the screen /* class...

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

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