FirstProg

FirstProg - double y = 6.5; int i; String txt =...

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

View Full Document Right Arrow Icon
public class FirstProg { // class wraps up a bunch of functions and variables // in Java parlance, we call them methods and fields / public static void main (String[] args) { /* this method must be present with this signature in order for the Java Virtual Machine (JVM) to execute the "program" */ int x =5; // all variables must be declared with types
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: double y = 6.5; int i; String txt = "hello world"; System.out.println(txt+" is "+txt.length()+" characters long"); for (i=0; i<10; i=i+1) { System.out.println(cuber(i)); } }// end main // this is a helper function // in Java parlance, a method definition public static int cuber (int num) { return num*num*num; } }// end class...
View Full Document

Ask a homework question - tutors are online