Connect Two Classes in Java

Connect Two Classes in Java:

We can use the Eclipse IDE for this example. If you do not know about it then follow this link- How to Install Eclipse For Java and create a program in it.

(1) In this blog, we can learn how to connect two classes in Java.

(2) We named the class and

(3) In class we define the objects and methods. We call these objects and methods in class as shown below. class:

java bike class - Connect Two Classes in Java
public class Bike {
    String maker = "Yamaha";
    String name = "R15";
    int year = 2015;
    String color = "red";
    double price = 100000.00;
    void drive() {
    	System.out.println("You drive the bike");
    void brake() {
    	System.out.println("You have to apply the brake");
} Class:

main java class - Connect Two Classes in Java
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Bike myBike = new Bike();


Tutorial MySQL
Tutorial Python
Procedure-Oriented Programming
Object-Oriented Programming
Modular Programming
Structured Programming
Java (programming language)– Wikipedia

Comments (No)

Leave a Reply