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

Basic Structure of Java

The document discusses the basic structure of a Java program including classes, methods, and input/output. It covers the main method, System.out, and print, println, and printf methods. It also covers single-line and multi-line comments in Java code.

Uploaded by

Ley Manalo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Basic Structure of Java

The document discusses the basic structure of a Java program including classes, methods, and input/output. It covers the main method, System.out, and print, println, and printf methods. It also covers single-line and multi-line comments in Java code.

Uploaded by

Ley Manalo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

JAVA PROGRAMMING

BASIC STRUCTURE OF JAVA


BASIC STRUCTURE OF JAVA
public class Main {
public static void main(String[ ] args) {
System.out.println("Hello and welcome!");
System.out.println("This is Java Programming!");
}
}
public class Main {
This is where we define a
class.
A Class name is created by
the programmer following the
rules in naming identifiers
A class can be declared as
public or private to access
data within a class.
public static void main(String[ ] args) {
This is the main method (core of the
program) in Java.
This is the entry point for executing a
Java program
Main method does not return anything
(Keyword: Void)
It can be called without creating an
object. (Keyword: static)
It accepts String type of arguments
Java Output
• System is a class
• out is a public static field:
it accepts output data.

• println() method to display


the string
https://www.programiz.com/java-programming/basic-input-output
Difference between println(), print() and printf()
print() - It prints string
inside the quotes.
println() - It prints string
inside the quotes similar
like print() method. Then the
cursor moves to the beginning
of the next line.
printf() - It provides string
formatting (similar to printf in C/
C++ programming).

https://www.programiz.com/java-programming/basic-input-output
Types of Comments in Java
Comments are a portion
of the program that are
completely ignored by
Java compilers.
They are mainly used to
help programmers to
understand the code.

single-line comment
https://www.programiz.com/java-programming/comments
Types of Comments in Java
This type of comment is
also known as
Traditional Comment.
In this type of comment,
the Java compiler
ignores everything
from /* to */.

multi-line comment https://www.programiz.com/java-programming/comments

You might also like