September 2018
Beginner
156 pages
3h 31m
English
Objects are instances or references of a class. So we can call the methods and variables present in this class with the help of their objects. We cannot call methods and objects directly, we can only use them with the help of their objects. So first, we need to create objects for the class, and then we can call the method inside the main class.
Let's take a look at the previous example to explain this:
package coreJavaTraining;public class Firstclass { public void getData() { System.out.println(" I am in method"); } public static void main(String[] args) { System.out.println("hi"); System.out.println("hello world"); }}
Since the main block is already in the class, why do we need to create an object ...
Read now
Unlock full access