Day 1: Introduction to Java
On this page
Goals:
- Understand the basics of Java and its platform.
- Set up the development environment.
Topics:
- What is Java? Overview and history
- Java is a high-level, class-based, object-oriented programming language designed to have as few implementation dependencies as possible.
- Developed by Sun Microsystems in 1995 and later acquired by Oracle Corporation.
- Java is widely used for building enterprise-scale applications, Android apps, and server-side applications.
- Installing Java Development Kit (JDK) and Integrated Development Environment (IDE)
- Java Development Kit (JDK) Installation:
- Download the latest JDK from the Oracle website or use an open-source version like AdoptOpenJDK.
- Follow the installation instructions for your operating system (Windows, macOS, or Linux).
- Integrated Development Environment (IDE) Installation:
- Popular IDEs for Java development include IntelliJ IDEA and Eclipse.
- Download IntelliJ IDEA from JetBrains website or Eclipse from Eclipse website.
- Follow the installation instructions for your operating system.
- Java Development Kit (JDK) Installation:
- Writing your first Java program (“Hello, World!”)
- Open your IDE and create a new Java project.
- Create a new Java class with the following code:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
- Basic syntax and structure of a Java program
- Class Definition: Every Java program must have at least one class definition.
- Main Method: The
mainmethod is the entry point of any Java program. - Statements: Each statement ends with a semicolon (
;). - System.out.println: This method is used to print text to the console.
Exercises:
- Write, compile, and run your first Java program:
- Write the “Hello, World!” program as shown above.
- Compile the program:
- In IntelliJ IDEA, click the green run button.
- In Eclipse, click the run button.
- Run the program to see the output.
- Experiment with different outputs:
- Modify the
System.out.printlnline to print different messages. - Example:
- Modify the
System.out.println("Welcome to Java programming!");
System.out.println("Java is fun!");
System.out.println("Let's learn more!");
By the end of Day 1, you should have a basic understanding of Java, have your development environment set up, and be able to write and run simple Java programs.
More in Unacategorized
See all →- Graph Theory Explained – SMA Welcome to Graph Theory! Graphs are fundamental structures used to model relationships between objects. They are made up of: Nodes (or Verti...
- Reinforcement Learning Viva Questions & Answer – MU AI & DS Semester 8 1 Introduction to Reinforcement Learning (4 Hours) Key features and Elements of RL Types of RL Rewards Reinforcement Learning Algorithms: Q-...
- Ensemble Learning Visualizer This interactive tool helps visualize how different ensemble learning methods work. Select a method below to explore step-by-step: Bagging:...
- Important Topics for Semester 3 Exam [CS/AI-DS/AI-ML/CSE] Important Topics for Semester 3 Exam [CS/AI-DS/AI-ML/CSE] MATHS-3 Laplace Transform (L) of standard functions First Shifting Theorem and Sec...
- NLP MOdule 4,5,6 PYQ Module 4: Semantic Analysis Questions: What is Word Sense Disambiguation (WSD)? Explain the dictionary based approach to Word Sense Disambig...
- What is the output of the following code? Integer p, q, r Set p=1, q=4, r=6 for (each r from 5 to 9 ) if(7< p && (4&r)