Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Beginners Java coding for beginners

 
 

Share on Google+Share on Google+

Java coding for beginners

Advertisement
In this Java coding for beginners example, we are running two different example of core Java that will print the variable values. In another Java beginner example, the program will ask you to enter the integer value and it will be printed to the console.

This article is for beginners who want to learn Java

Tutorials of this section are especially for the beginners who want to incept the Java program from very beginning. Tutorial Java coding for beginners will enable you to know about the Java Coding and its various aspects during programming. It also introduces you with the Java Programming language and coding.

In this topic, students will have to know about the lists of simple Java Codes and basic Program for beginners. There are various lists of Java simple Codes for those who are beginners for the program. It you want to test these codes then you can use the java compiler you have for the purposes.

Echoing words in Java to output words in Java use the pre-defined function System.out.print().Here is the complete source codes for outputting word in Java.

Java coding for beginners example 1

public class Main
{
  public static void main(String[] args)
   {
      System.out.print("This is just an example...");
   }
}
Output: This is just an example...

Inputting and Echoing integer and string entered by user

If the program prompt input from user their will be declaration of variables. See the source codes below:

Java coding for beginners example 2

import java.util.Scanner; //to be able to use scanner predefined function for input

public class Main
{
    public static void main(String[] args)
    {

    Scanner input = new Scanner(System.in); // choose your own too.

    int num1; //num1 is a variable of integer type you can change it
    String word1; //string type variable that cab be changed.
    System.out.print("Enter a number and I will echo it later: ");

    num1=input.nextInt(); //read input for num1

    System.out.print("Enter a word and I will echo it later: ");

    word1 = input.next(); //read input for word1

    System.out.println("Here is the echo of what you have entered:");

    System.out.println("The number you have entered is: " + num1); //echoing input to num1

    System.out.println("The word you have entered is: " + word1); //echoing input to word1
    }
}

Here is more tutorials for Java coding for beginners

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: December 11, 2013

Related Tutorials

Discuss: Java coding for beginners  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com