Category: Education

Java Programs for Beginners | How to Start coding in JAVA?

Java Programs for Beginners | How to Start coding in JAVA?

JAVA for Beginners

I had written some basic programs that will surely help you to start coding in JAVA. Java is a simple programming language if you are having a bit of programming concept or if you had already coded in C C++ or any popular language.

If not coded in any of the languages, still it will not be difficult for you to start coding in JAVA.

Lets start with some basic programs.

For printing “Welcome to Java!” :

package chapter1;

public class Welcome { 

  public static void main(String[] args) {

    System.out.println(“Welcome to Java!”);



We just created a package named Chapter 1 and a class named Welcome. Also a public Main function also known as the driver function.

System.out.println – is used for printing just like cout in C++.


Package specifies a package name, Packname, for the class Welcome. Java Compiler compiles the source code in, generates Welcome.class, and stores Welcome.class in the Project  folder.

Reserved Words/ Key Words

  • Key words / Reserved words are those words whose meaning already defined by compiler.

  • Cannot be used as Variable Name


Java uses certain reserved words called modifiers that specify the properties of the data, methods, and classes and how they can be used. Examples of modifiers are public and static. Other modifiers are private, final, abstract, and protected. A public datum, method, or class can be accessed by other programs. A private datum or method cannot be accessed by other programs.


  • An instruction

  • int num;

  • System.out.println(“Hello”);


A pair of braces in a program forms a block that groups components of a program.



The class is the essential Java construct. A class is a template or blueprint for objects. To program in Java, you must understand classes and be able to write and use them.


What is System.out.println? It is a method: a collection of statements that performs a sequence of operations to display a message on the console. It can be used even without fully understanding the details of how it works. It is used by invoking a statement with a string argument. The string argument is enclosed within parentheses. In this case, the argument is “Welcome to Java!” You can call the same println method with a different argument to print a different message.

Main Method

  • Public static void main(String args[])

  • Where program execution starts.

  • String args[] is string an array use for command line arguments.

Primitive Data Types and Operations

Identifiers, Variables, and Constants

Primitive Data Types

  • byte, short, int, long, float, double, char, boolean


Operators, Precedence, Associativity, Operand Evaluation Order: ++, –, *, /, %, +=, -=, *=, /=, %=, ^, &, |, +, -,


  • An identifier is a sequence of characters that consist of letters, digits, underscores (_), and dollar signs ($).

  • An identifier must start with a letter, an underscore (_), or a dollar sign ($). It cannot start with a digit.

  • An identifier cannot be a reserved word.

  • An identifier can be of any length.


final datatype CONSTANTNAME = VALUE;  

final double PI = 3.14159;

final int SIZE = 3;

Numerical Data Types

byte            8 bits

short          16 bits

int            32 bits

long           64 bits

float          32 bits

double         64 bits


+, -, *, /, and %

5/2 yields an integer 2.

5.0/2 yields a double value 2.5

5 % 2 yields 1 (the remainder of the division)

Number Literals

  • Floating-point literals are written with a decimal point. By default, a floating-point literal is treated as a double type value. For example, 5.0 is considered a double value, not a float value. You can make a number a float by appending the letter f or F, and make a number a double by appending the letter d or D. For example, you can use 100.2f or 100.2F for a float number, and 100.2d or 100.2D for a double number.

Numeric Type Conversion

Consider the following statements:

byte i = 100;

long k = i*3+4;

double d = i*3.1+k/2;

int x = k; //(Wrong)

long k = x; //(fine,implicit casting)


To use comments in java programming, we use the following syntax:

//Single line
/*Multi line*/

Any Questions? Suggestions? Ideas? please share with us by commenting below 🙂
Java IDE Tools | Most Used Java IDE

Java IDE Tools | Most Used Java IDE

Java IDE Tools

There are many Java IDE tools that can be used to code in java. Some of the major IDE are:



Forte by Sun Microsystems

Borland JBuilder

Microsoft Visual J++

WebGain Café

IBM Visual Age for Java


Most used java IDE:


Any Questions? Suggestions? Ideas? please share with us by commenting below 🙂

Stay connected for more posts regarding this topic 🙂

Learn Java Concepts | Why JAVA? | Java Features

Learn Java Concepts | Why JAVA? | Java Features

History of the JAVA Language :

  • Java is a general-purpose, object-oriented programming language developed by Sun Micro-systems of USA in 1991.
  • Originally called Oak by James Gosling (one of the inventor of the language).
  • Java was invented for the development of software for consumer electronic
  • Working on Interactive TV Project (mid 1990’s).
  • Frustrated with the Language C/C++.
  • Gosling holed up in his office and created a new language that was suitable for his project and addressed some of the things that frustrated him about C++.
  • Java was released by Sun in 1995.

Usually people ask about Java this same question ie. Why java? or Why we use java programming instead of other programming languages?

The answer is..

Platform in dependency :-
Java is one of the few programming languages that are platform independent. the java programs are usually compiled down to a bytecode which is platform independent.
This bytecode is run on a Java Virtual Machine (JVM).

Thus this makes Java a unique language to be used for programming.


Some of the major features of Java are :

  1. Compiled and Interpreted
  2. Platform Independent and portable
  3. Object- oriented
  4. Robust and secure
  5. Distributed
  6. Familiar, simple and small
  7. Multi-threaded and Interactive
  1. Compiled and Interpreted :

    Basically a computer language is either compiled or interpreted. Java comes together both these approach thus making Java a two-stage system.

    Java compiler translates Java code to Bytecode instructions and Java Interpreter generate machine code that can be directly executed by machine that is running the Java program.

  2. Platform Independent and portable :

    Java supports the feature portability. Java programs can be easily moved from one computer system to another and anywhere.

    Changes and upgrades in operating systems, processors and system resources will not force any alteration in Java programs.

    This is reason why Java has become a trendy language for programming on Internet which interconnects different kind of systems worldwide. Java certifies portability in two ways.

    First way is, Java compiler generates the bytecode and that can be executed on any machine.

    Second way is, size of primitive data types are machine independent.

  3. Object- oriented :

    Java is truly object-oriented language. In Java, almost everything is an Object. All program code and data exist in objects and classes.

    Java comes with an extensive set of classes; organize in packages that can be used in program by Inheritance. The object model in Java is trouble-free and easy to enlarge.

  4. Robust and secure :

    Java is a most strong language which provides many securities to make certain reliable code. It is design as garbage –collected language, which helps the programmers virtually from all memory management problems. Java also includes the concept of exception handling, which detain serious errors and reduces all kind of threat of crashing the system.

    Security is an important feature of Java and this is the strong reason that programmer use this language for programming on Internet. The absence of pointers in Java ensures that programs cannot get right of entry to memory location without proper approval.

  5. Distributed :

    Java is called as Distributed language for construct applications on networks which can contribute both data and programs. Java applications can open and access remote objects on Internet easily.

    That means multiple programmers at multiple remote locations to work together on single task.

  6. Simple and small :

    Java is very small and simple language. Java does not use pointer and header files, goto statements, etc. It eliminates operator overloading and multiple inheritance.

  7. Multi-threaded and Interactive :

    Multi-threaded means managing multiple tasks simultaneously. Java maintains multi-threaded programs. That means we need not wait for the application to complete one task before starting next task. This feature is helpful for graphic applications.

There are certain evaluation criteria for a language to be accepted:

  1. External Evaluation criteria :


  • Rapid development
  • Programmers are more expensive than machines, so they’d better be able to make fast progress.
  • Easy maintenance
  • Maintenance is expensive.
  • Reliability and safety
  • When computers go down, planes crash, phone systems break, nuclear reactors melt down, cash machines close. We’d like to avoid this.
  • Portability
  • I’d like my program to run on many different platforms, with minimal rewriting.
  • Efficiency
  • The compiler should be fast. The code itself should be fast.Low training time (learn-ability)The language should be easy to learn. Training is expensive.
  • Re-usability
  • Writing software components once is cheaper than writing them twice.
  • Pedagogical value
  • The language should support and enforce the concepts you want to teach.

    2. Internal Evaluation Criteria :


  • Readability
  • Understand what you, or someone else has written.
  • Write-ability
  • Say what you mean, without excessive verbiage.
  • Simplicity
  • The language should have a minimal number of primitive concepts/features.
  • Orthogonality
  • The language should support the combination of its concepts/features in a meaningful way.
  • Consistency
  • The language should not include needless inconsistencies. (But remember Ralph Waldo Emerson: “A foolish consistency is the hobgoblin of small minds.”)
  • Expressiveness
  • The programmer should be able to express their algorithm naturally.
  • Abstraction
  • The language should support a high level of data and control abstraction.
Any Questions? Suggestions? Ideas? please share with us by commenting below 🙂
Stay connected for more posts regarding this topic 🙂

(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

ga(‘create’, ‘UA-98657495-1’, ‘auto’);
ga(‘send’, ‘pageview’);