buildin class in java code example
Example 1: how to make an objec tjava
class Puppy() {
String name;
int age;
Puppy(String puppy_name, int puppy_age) {
name = puppy_name;
age = puppy_age;
}
public static void main(String[] args) {
Puppy rex = new Puppy("rex",4);
}
}
Example 2: java class
// Example : TestClass (Can be predefined or user-defined)
public class TestClass {
// properties
private int id = 111;
// constructor
public TestClass(){
super();
}
// method
public void test(){
// some code here
}
}