java classes and objects
class Dog {
int age = 5;
public static void main(String[]args) {
Dog myObj = new Dog();
System.out.println(myObj.age);
}
}
java classes and objects
class Dog {
int age = 5;
public static void main(String[]args) {
Dog myObj = new Dog();
System.out.println(myObj.age);
}
}
object in java
Objects: came from class, we can create multiple objects from a class
ArrayList<> list = new ArrayList<>();
Class refName OBJECT
each object has its own copy of instance variable
· declared outside the blocks or methods
Object: Instance of the class. We can store different data's to objects
Object Creation: with new keyword.
ClassName obj = new ExistingConstructor;
Java Class
public class Main {
int x = 5;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us