A JAVA PROGRAM

Java Fundamentals Tutorial: Hello World

This is very helpful article for IT aspirant

Guided by Bipin Ajay


2. A Java Hello World Program

Implementing Hello World in Java

2.1. HelloWorld.java

public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
  • All code is contained within a class, in this case HelloWorld.
  • The file name must match the class name and have a .java extension, for example: HelloWorld.java
  • All executable statements are contained within a method, in this case named main().
  • Use System.out.println() to print text to the terminal.

Classes and methods (including other flow-control structures) are always defined in blocks of code enclosed by curly braces ({ }).

All other statements are terminated with a semi-colon (;).

Java language is case-sensitive! This means that HelloWorld is not the same as helloworld, nor is String the same as string.

There is an generally accepted naming convention in the Java community to capitalize the names of Java classes and use the so-called CamelCase (or CamelHump) notation, where the first letter of each word is capitalized, but the words are joined together (i.e. no dashes or underscores).

[Note]

Note

Java source files can be encoded in UTF-8 to support internationalized characters (even for class, method, and variable names). In most situations however, Java sources are stored in US-ASCII character set, and internationalized strings are loaded from external resource files.

Thank you

Tech Jitendra

Published by Tech Jitendra Direct Investing

Tech Jitendra Direct Investing (TJDI) Empoworing Your Wealth

Leave a comment

Design a site like this with WordPress.com
Get started