0% found this document useful (0 votes)
4 views

Day+1+-+Intro+to+Java

The document provides an introduction to Java, highlighting its development, features, and syntax, making it beginner-friendly and robust for web and enterprise applications. It also introduces JDoodle, an online Java coding tool that allows users to code without installation and provides instant feedback. Additionally, it covers common printing errors, error-solving strategies using resources like Stack Overflow, and emphasizes Java's versatility and community support.

Uploaded by

aligangajake10.3
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Day+1+-+Intro+to+Java

The document provides an introduction to Java, highlighting its development, features, and syntax, making it beginner-friendly and robust for web and enterprise applications. It also introduces JDoodle, an online Java coding tool that allows users to code without installation and provides instant feedback. Additionally, it covers common printing errors, error-solving strategies using resources like Stack Overflow, and emphasizes Java's versatility and community support.

Uploaded by

aligangajake10.3
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 44

INTRODUCTI0N TO

JAVA
About Java
Development: Java, created by James
Gosling at Sun Microsystems in 1995, is
portable and robust for web and enterprise.
About Java
Development: Java, created by James
Gosling at Sun Microsystems in 1995, is
portable and robust for web and enterprise.

Syntax and Learning Curve: Java's English-


like syntax is beginner-friendly, with Core and
Advanced phases; C/C++ knowledge helps.
Features Of Java
Simple: Java’s syntax is easy to understand, much like
learning to ride a bicycle from basics.
Features Of Java
Simple: Java’s syntax is easy to understand, much like
learning to ride a bicycle from basics.

Object-Oriented: OOP provides modular, reusable code


for complex problems.
Features Of Java
Simple: Java’s syntax is easy to understand, much like
learning to ride a bicycle from basics.

Object-Oriented: OOP provides modular, reusable code


for complex problems.

Platform-Independent: Java runs on any device with


JVM, WORA language.
Features Of Java
Simple: Java’s syntax is easy to understand, much like
learning to ride a bicycle from basics.

Object-Oriented: OOP provides modular, reusable code


for complex problems.

Platform-Independent: Java runs on any device with


JVM, WORA language.

Secure: Java offers secure execution with memory


management, exception handling, and access control.
Introduction to JDoodle
Introduction: JDoodle is an online Java code tool, ideal for
beginners.
Introduction to JDoodle
Introduction: JDoodle is an online Java code tool, ideal for
beginners.

No Installation Required: Code immediately without


installing Java or environment.
Introduction to JDoodle
Introduction: JDoodle is an online Java code tool, ideal for
beginners.

No Installation Required: Code immediately without


installing Java or environment.

User-Friendly Interface: Simple editor and buttons to


compile and run code.
Introduction to JDoodle
Introduction: JDoodle is an online Java code tool, ideal for
beginners.

No Installation Required: Code immediately without


installing Java or environment.

User-Friendly Interface: Simple editor and buttons to


compile and run code.

Instant Feedback: One-click compile and run with instant


output.
Introduction to JDoodle
Introduction: JDoodle is an online Java code tool, ideal for
beginners.

No Installation Required: Code immediately without


installing Java or environment.

User-Friendly Interface: Simple editor and buttons to


compile and run code.

Instant Feedback: One-click compile and run with instant


output.

Free to Use: Free tier for beginners, paid options for


advanced features.
Displaying Text On The Screen
Introduction: In Java, you can display text using the
System.out.println command. This command shows the text and 3
moves to a new line.
Displaying Text On The Screen
Introduction: In Java, you can display text using the
System.out.println command. This command shows the text and 3
moves to a new line.

Example: System.out.println("Hello, World!");

Explanation:
- System.out.println: Tells the computer to display text.
- Parentheses (): Enclose the text to be shown.
- Double Quotes "": Enclose the exact text to be displayed.
- Semicolon ;: Ends the instruction.
Displaying Text On The Screen
Introduction: In Java, you can display text using the
System.out.println command. This command shows the text and 3
moves to a new line.

Example: System.out.println("Hello, World!");

Explanation:
- System.out.println: Tells the computer to display text.
- Parentheses (): Enclose the text to be shown.
- Double Quotes "": Enclose the exact text to be displayed.
- Semicolon ;: Ends the instruction.

Another Example: System.out.println("Good Morning");


Displaying Text On The Screen
Introduction: In Java, you can display text using the
System.out.println command. This command shows the text and 3
moves to a new line.

Example: System.out.println("Hello, World!");

Explanation:
- System.out.println: Tells the computer to display text.
- Parentheses (): Enclose the text to be shown.
- Double Quotes "": Enclose the exact text to be displayed.
- Semicolon ;: Ends the instruction.

Another Example: System.out.println("Good Morning");

Syntax: Follow Java's syntax rules: enclose text in double quotes


within parentheses and end with a semicolon.
Breaking Down Code
Class: A class is like a big box where we keep our instructions. It’s the robot's
instruction manual. We name this box 'MyClass'.
Breaking Down Code
Class: A class is like a big box where we keep our instructions. It’s the robot's
instruction manual. We name this box 'MyClass'.

Main Method: The main method is the starting point. It tells the computer
where to begin reading instructions, like the first page of an instruction
manual.
Breaking Down Code
Class: A class is like a big box where we keep our instructions. It’s the robot's
instruction manual. We name this box 'MyClass'.

Main Method: The main method is the starting point. It tells the computer
where to begin reading instructions, like the first page of an instruction
manual.

Code: public class MyClass {


public static void main(String[] args){
System.out.println("Hello, world!");
}
}
Breaking Down Code
Class: A class is like a big box where we keep our instructions. It’s the robot's
instruction manual. We name this box 'MyClass'.

Main Method: The main method is the starting point. It tells the computer
where to begin reading instructions, like the first page of an instruction
manual.

Code: public class MyClass {


public static void main(String[] args){
System.out.println("Hello, world!");
}
}
Code Breakdown: Public: Anyone can see this. Class: Describes a new thing.
MyClass: Name of our box (class).{}: Marks the start and end of the class.
Breaking Down Code
Class: A class is like a big box where we keep our instructions. It’s the robot's
instruction manual. We name this box 'MyClass'.

Main Method: The main method is the starting point. It tells the computer
where to begin reading instructions, like the first page of an instruction
manual.

Code: public class MyClass {


public static void main(String[] args){
System.out.println("Hello, world!");
}
}
Code Breakdown: Public: Anyone can see this. Class: Describes a new thing.
MyClass: Name of our box (class).{}: Marks the start and end of the class.

Main Method Details:


- Public: Anyone can see this.
- Static: Fixed part that doesn't change.
- Void: No return value.
- Main: Starting point.
- (String[] args): Extra information.
-{}: Marks the start and end of the main method.
Breaking Down Code
Class: A class is like a big box where we keep our instructions. It’s the robot's
instruction manual. We name this box 'MyClass'.

Main Method: The main method is the starting point. It tells the computer
where to begin reading instructions, like the first page of an instruction
manual.

Code: public class MyClass {


public static void main(String[] args){
System.out.println("Hello, world!");
}
}
Code Breakdown: Public: Anyone can see this. Class: Describes a new thing.
MyClass: Name of our box (class).{}: Marks the start and end of the class.

Main Method Details:


- Public: Anyone can see this.
- Static: Fixed part that doesn't change.
- Void: No return value.
- Main: Starting point.
- (String[] args): Extra information.
-{}: Marks the start and end of the main method.

Print Command:
- System.out.println: Command to print text.
- ("Hello, world!"): Text to display.
-; : End of instruction.
Common Printing Errors
Misspelling System.out.println:
Error: System.out.prinln or Systm.out.println
Correct: System.out.println

3
Common Printing Errors
Misspelling System.out.println:
Error: System.out.prinln or Systm.out.println
Correct: System.out.println

Forgetting Semicolons: 3
Error: System.out.println("Hello World")
Correct: System.out.println("Hello World");
Common Printing Errors
Misspelling System.out.println:
Error: System.out.prinln or Systm.out.println
Correct: System.out.println

Forgetting Semicolons: 3
Error: System.out.println("Hello World")
Correct: System.out.println("Hello World");

Mismatched Parentheses and Quotes:


Error: System.out.println("Hello World); or System.out.println(Hello World");
Correct: System.out.println("Hello World");
Common Printing Errors
Misspelling System.out.println:
Error: System.out.prinln or Systm.out.println
Correct: System.out.println

Forgetting Semicolons: 3
Error: System.out.println("Hello World")
Correct: System.out.println("Hello World");

Mismatched Parentheses and Quotes:


Error: System.out.println("Hello World); or System.out.println(Hello World");
Correct: System.out.println("Hello World");

Incorrect Main Method Declaration:


Error: public static void main(String args)
Correct: public static void main(String[] args)
Common Printing Errors
Misspelling System.out.println:
Error: System.out.prinln or Systm.out.println
Correct: System.out.println

Forgetting Semicolons: 3
Error: System.out.println("Hello World")
Correct: System.out.println("Hello World");

Mismatched Parentheses and Quotes:


Error: System.out.println("Hello World); or System.out.println(Hello World");
Correct: System.out.println("Hello World");

Incorrect Main Method Declaration:


Error: public static void main(String args)
Correct: public static void main(String[] args)

Not Using Correct Case Sensitivity:


Error: system.out.println("Hello World");
Correct: System.out.println("Hello World");
Common Printing Errors
Misspelling System.out.println:
Error: System.out.prinln or Systm.out.println
Correct: System.out.println

Forgetting Semicolons: 3
Error: System.out.println("Hello World")
Correct: System.out.println("Hello World");

Mismatched Parentheses and Quotes:


Error: System.out.println("Hello World); or System.out.println(Hello World");
Correct: System.out.println("Hello World");

Incorrect Main Method Declaration:


Error: public static void main(String args)
Correct: public static void main(String[] args)

Not Using Correct Case Sensitivity:


Error: system.out.println("Hello World");
Correct: System.out.println("Hello World");

Misplacing or Missing Braces:


Error: Forgetting to include braces {} around the code block.
Correct: Always include opening { and closing } braces.
How to Search for Errors
Copy the Error Message: Copy the error message
when it appears.
How to Search for Errors
Copy the Error Message: Copy the error message
when it appears.

Ask ChatGPT for Help: Paste the error message in


ChatGPT for assistance.
How to Search for Errors
Copy the Error Message: Copy the error message
when it appears.

Ask ChatGPT for Help: Paste the error message in


ChatGPT for assistance.

Understand the Solution: Read and understand


ChatGPT's explanation and solution.
How to Search for Errors
Copy the Error Message: Copy the error message
when it appears.

Ask ChatGPT for Help: Paste the error message in


ChatGPT for assistance.

Understand the Solution: Read and understand


ChatGPT's explanation and solution.

Implement the Solution: Apply ChatGPT's suggested


changes to your code.
How to Search for Errors
Copy the Error Message: Copy the error message
when it appears.

Ask ChatGPT for Help: Paste the error message in


ChatGPT for assistance.

Understand the Solution: Read and understand


ChatGPT's explanation and solution.

Implement the Solution: Apply ChatGPT's suggested


changes to your code.

Verify the Fix: Run your program again to ensure the


error is fixed.
Error Solution Using
Stack Overflow
Introducing Stack Overflow: A community for programmers to
3
ask and answer coding questions.
Error Solution Using
Stack Overflow
Introducing Stack Overflow: A community for programmers to
3
ask and answer coding questions.

Read Existing Answers: Check if someone has already solved


your problem.
Error Solution Using
Stack Overflow
Introducing Stack Overflow: A community for programmers to
3
ask and answer coding questions.

Read Existing Answers: Check if someone has already solved


your problem.

Ask a Question: Post your own question with a clear title,


description, error messages, and code.
Error Solution Using
Stack Overflow
Introducing Stack Overflow: A community for programmers to
3
ask and answer coding questions.

Read Existing Answers: Check if someone has already solved


your problem.

Ask a Question: Post your own question with a clear title,


description, error messages, and code.

Example: Search for error: ';' expected with the Java prefix on
Stack Overflow.
Error Solution Using
Stack Overflow
Introducing Stack Overflow: A community for programmers to
3
ask and answer coding questions.

Read Existing Answers: Check if someone has already solved


your problem.

Ask a Question: Post your own question with a clear title,


description, error messages, and code.

Example: Search for error: ';' expected with the Java prefix on
Stack Overflow.

Beyond Stack Overflow: If needed, use Google, ask friends, or


post on other Java communities.
Additional Java Features
Open Source: Active community provides help,
shares knowledge, and solves problems.
Additional Java Features
Open Source: Active community provides help,
shares knowledge, and solves problems.

Fully Documented: Extensive documentation offers


step-by-step guides and solutions.
Additional Java Features
Open Source: Active community provides help,
shares knowledge, and solves problems.

Fully Documented: Extensive documentation offers


step-by-step guides and solutions.

Versatility: Used in web development, mobile


apps, enterprise solutions, cloud computing, and
IoT.
Additional Java Features
Open Source: Active community provides help,
shares knowledge, and solves problems.

Fully Documented: Extensive documentation offers


step-by-step guides and solutions.

Versatility: Used in web development, mobile


apps, enterprise solutions, cloud computing, and
IoT.

Strong Community Support: Active community


provides help, shares knowledge, and solves
problems.
Printing Examples
Printing Text (Strings): System.out.println("This is a string.");

Printing Numbers: System.out.println(123); // Integer


System.out.println(45.67); // Floating-point number 3

Using print Instead of println:


System.out.print("Hello, ");
System.out.print("World!");

Adding New Lines with \n: System.out.print("Hello,\nWorld!");

Putting It All Together:


public class Main {
public static void main(String[] args) {
System.out.println("Hello, World!"); //Hello, World!
System.out.println(42); //42
System.out.println(3.14); //3.14
System.out.print("This is ");
System.out.print("on the same line."); //This is on the same line.
}
}

You might also like