Tutorial.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | package tutorial; public class Tutorial { public static void main(String[] args) { // TODO code application logic here simple program that will just print out the numbers 1 to 5 for ( int i = 1 ; i < 6 ; i++) { System.out.println(i); } Person p = new Person( "Mike" ); p.displayName(); } } |
Person.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | package tutorial; public class Person { private String name; /** Create a new instance of person */ public Person(String n) { name = n; } //display the name public void displayName() { System.out.println(name); } } |