You can create classes in java that contain fields, properties, and methods but when you compile the compiler is looking for a class called "Main." It looks for this because the "Main" is where the code is actually ran. Inside of Main you can create instances of objects, use methods, and have output to the user
public class Instructor {
String Fname;
String Lname;
String Department;
String Email;
public Instructor(String fname,String lname,String department, String email){
this.Fname=fname;
this.Lname=lname;
this.Department=department;
this.Email=email;
}
public String getFname() {
return Fname;
}
public void setFname(String fname) {
Fname = fname;
}
public String getLname() {
return Lname;
}
public void setLname(String lname) {
Lname = lname;
}
public String getDepartment() {
return Department;
}
public void setDepartment(String department) {
Department = department;
}
public String getEmail() {
return Email;
}
public void setEmail(String email) {
Email = email;
}
public static void main(String[] args){
Instructor abc = new Instructor("abdul","arun",".net","a@a.com");
System.out.println(abc.Department);
System.out.println(abc.Email);
System.out.println(abc.Fname);
System.out.println(abc.Lname);
}
}
********************************************************************************
output
.net
a@a.com
abdul
arun
********************************************************************************
Post a Comment