Answers for "call function in java class"

3

how to call a function in java

public class MyClass {
 
    static void myMethod() {
        System.out.println("You have called me! My name is: myMethod!");
    }
 
    public static void main(String[] args) {
        myMethod();
    }
}
Posted by: Guest on February-24-2021
3

how to call a function in java

public class MyClass {
 
    static void myMethod() {
        System.out.println("You have called me! My name is: myMethod!");
    }
 
    public static void main(String[] args) {
        myMethod();
    }
}
Posted by: Guest on February-24-2021
1

how to call a function from a class java

public class Classroom {
	 private String teacherName;
	
  	 public Classroom(String teacherName){
       this.teacherName = teacherName;
     }
  
  	 public String getTeacherName() {
        return teacherName;
     } 
}

public static void main(String[] args){
	Classroom firstGrade = new Classroom("John");
    /*Once you type the 'firstGrade.' your IDE most likely 
	will show all the functions it can acess*/
    firstGrade.getTeacherName();
}
Posted by: Guest on March-30-2021
1

how to call a function from a class java

public class Classroom {
	 private String teacherName;
	
  	 public Classroom(String teacherName){
       this.teacherName = teacherName;
     }
  
  	 public String getTeacherName() {
        return teacherName;
     } 
}

public static void main(String[] args){
	Classroom firstGrade = new Classroom("John");
    /*Once you type the 'firstGrade.' your IDE most likely 
	will show all the functions it can acess*/
    firstGrade.getTeacherName();
}
Posted by: Guest on March-30-2021

Code answers related to "call function in java class"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language