A class is a blueprint of object. In java, class is a keyword, you can not use this keyword to name a variable because it is reserved to represent a class. In a class you can create other classes, you can create methods, create global variables and etc. Below is an example of a class Student.
You can use that class by creating the object class first like in the example below :
Thank you for visiting our website. Just comment below if you have any question to ask.
package com.example.myapplication.alert;
/**
* Created by SONY on 17/10/2016.
*/
public class Student {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
You can use that class by creating the object class first like in the example below :
Student student = new Student();
student.setName("Robert");
String name = student.getName();
Thank you for visiting our website. Just comment below if you have any question to ask.
No comments:
Post a Comment