1public class Main {
2
3 public static void main(String[] args) {
4 System.out.println("Hello, World!");
5 }
6
7}
1public static void main(String[] args){
2 System.out.println("Hello World");
3}
1public class className{
2 public static void main(String[] args){
3 System.out.println("Hello World"); // println brings into a new line and print doen't
4 }
5}
1class HelloWorld {
2 public static void main(string[] args) {
3 System.out.println("Hello World!");
4 }
5}
1import javax.swing.JFrame; //Importing class JFrame
2import javax.swing.JLabel; //Importing class JLabel
3public class HelloWorld {
4 public static void main(String[] args) {
5 JFrame frame = new JFrame(); //Creating frame
6 frame.setTitle("Hi!"); //Setting title frame
7 frame.add(new JLabel("Hello, world!"));//Adding text to frame
8 frame.pack(); //Setting size to smallest
9 frame.setLocationRelativeTo(null); //Centering frame
10 frame.setVisible(true); //Showing frame
11 }
12}
1//Print Hello World in Java
2
3public class HelloWorld {
4 public static void main(String[] args) {
5 System.out.println("Hello, World!");
6 }
7}