Team2/Creating a Java Class

From CDOT Wiki
Jump to: navigation, search

Guide Line

  • To create a java class, right click on the package we created earlier (firstAPP) then highlight "New" and scroll down to "Class"
  • Under the name text box, enter "Lab1" and click on the button "Finish"
  • Copy and paste the following code
package firstAPP;

public class LabExercise1 {
    public int c;
   
    public LabExercise1(){
        c=4;
    }
    public void printHello() {
        System.out.println("Hello");
    }
    public int returnC(){
        return c;
    }
}
  • We will be using this sample code as we continue with this tutorial