Learn the fundamentals of object-oriented programming with Java. Build enterprise-level applications and develop strong programming foundations that will serve you throughout your career.
Java is used by millions of developers worldwide and powers enterprise applications at major companies.
Learn fundamental OOP concepts that apply to many programming languages and software design patterns.
Write once, run anywhere. Java code runs on any device with a Java Virtual Machine installed.
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
System.out.println("Welcome to Java programming!");
}
}import java.util.Scanner;
public class Calculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter first number: ");
double num1 = scanner.nextDouble();
System.out.print("Enter second number: ");
double num2 = scanner.nextDouble();
System.out.print("Enter operation (+, -, *, /): ");
char operation = scanner.next().charAt(0);
double result = 0;
switch(operation) {
case '+':
result = num1 + num2;
break;
case '-':
result = num1 - num2;
break;
case '*':
result = num1 * num2;
break;
case '/':
result = num1 / num2;
break;
default:
System.out.println("Invalid operation!");
return;
}
System.out.println("Result: " + result);
}
}public class Student {
private String name;
private int age;
private double gpa;
// Constructor
public Student(String name, int age, double gpa) {
this.name = name;
this.age = age;
this.gpa = gpa;
}
// Getter methods
public String getName() {
return name;
}
public int getAge() {
return age;
}
public double getGpa() {
return gpa;
}
// Method to display student info
public void displayInfo() {
System.out.println("Name: " + name);
System.out.println("Age: " + age);
System.out.println("GPA: " + gpa);
}
// Main method to test the class
public static void main(String[] args) {
Student student1 = new Student("Alice", 16, 3.8);
student1.displayInfo();
}
}Join thousands of students who have mastered Java programming with our interactive platform. Start with basics and progress to building real-world applications.