Today I learned class and method
How it's work with Example:
Your code defines a Bike class with attributes like name, model, milage, and cc. The getInformation() method prints out some of these attributes
class Bike{
String name;
int model;
int milage;
String cc;
public void getInformation(){
System.out.println(name);
System.out.println(model);
System.out.println(milage);
System.out.println(cc)
}
public static void main (String ar[]){
Bike yamaha = new Bike();
yamaha.name = "two wheeler";
yamaha.model = 2023;
yamaha.milage = 50;
yamaha.cc = "200";
yamaha.getInformation();
}
}
Top comments (1)
💥