Tuesday, 25 November 2014

Hey friends, this is an example of a simple java program which takes an input from the user.


Hey friends, welcome to simplyjavapro,


Well Its been quiet a lot of time since you've had known about Data types in Java.


So, lets get stated and try to do some really stuff in Java Programming.

Have you ever wondered how does the computer access that you "Input" and process it to give you a desired Output. Well, it is nothing but a set of codes, which make it possible.

In a powerful programming language, such as Java, you are expected to "import" the ability to use the Input/Output devices.


The first thing that you need to do in java to enable I/O(input-output) is to the following line of code before you mention your class.

import java.io.*;

The statement above imports a package called "io" from the java library which enables you to do input and output stuff in your programs.

The next step is obviously to mention your class, and then the main method.

class InputOutputExample
{

        public static void main(String args[]) throws IOException
       {
                 //Block of code              
        }
}
The code "throws IOException" takes care for any abnormalities that may occur during an IO.

Notice the double slashes used inside the main method. These indicate single line comments in Java.We shall discuss more about comments later. For now, you may consider that the line written in such a manner is not a part of the executable code.

In place of the Commented section you've got to use a few Classes to enable standard I/O in your program.

Write the following line of code:

InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(isr);


The above two lines allow you to take input from the standard input device, the keyboard (thanks to System.in)


Now take input using the readLine() method of the BufferedReader class.

Write the following line of code:

String input=br.readLine();


and this is it....

You have got your input from the keyboard. Now you could use it whichever way you like, print it perhaps.

System.out.println(input);

now just close your main methods and your class. Compile and run your code.

During the interpretation of the code(or during the time you program is running) your programs halts to take the input, type in any string and press ENTER.

and there you have your output.


Monday, 17 November 2014

class DataTypes
{
          public static void main(String args[])
         {
                  int a;
                  a=5;
                  float f=3.14;
                  boolean b=true;
                  String s="smaple string";
                  System.out.println("a= "+a);
                  System.out.println("f= "+f);
                  System.out.println("b= "+b);
                  System.out.println("s= "+s);
          }

}

Saturday, 15 November 2014

Hey friends, welcome to simplyjaavapro. Today, I shall discuss about data types in java.

Well, you may have heard that Java is a highly typed language.  The statement basically means that there exists a set of semantics for data types in Java programming language. Java provides data types under broad categories:


1. Pre -defined data types: These come in naturally with Java. They include:

i.  For integral Numbers         : int, short, long
ii. For floating point Numbers : float
iii.For characters                 : char


2. User - defined data type: These are defined by the user.


Note: A user defined data-type is basically an object reference to some object. One such data type comes pre-defined, called String.


Note: String is not rigidly a pre-defined data-type, although it may seem to be. It is actually an Object reference similar to any other user defined data type.

Friday, 7 November 2014

Hey friends,


Welcome to simplyjaavapro,  today I will discuss about your first java program.


Yes, you guessed it right ! It is the most famous problems of all times..to print a message called Hello, World on the screen.

If this sounds to be boring, you can print whatever you may feel like.

The code goes like this:


class MyFirstJaavaProgram
{
         public static void main(String args[])
         {
                   System.out.println("Hello, World "); // You can type your message within the quotes 
          }
 }

-------------------------------------------------------------------------------------------------------------------

Yes, this is it. Now save the file as MyFirstJaavaProgram.java 

Next you need to open up your terminal window (or a command prompt), and give the following command:

javac MyFirstJaavaProgram.java

java MyFirstJaavaProgram


----------------------------------------------------------------------------------------------------------------

And there you go, your first java program has been created, compiled and executed.

Tuesday, 4 November 2014

Hello everyone, this is a guide to install openjdk (Java Development Kit for Open Source) on your linux-based Operating System.


Following are  instructions that you need to follow:


1. open up a terminal (you may use ctrl + alt + t)

2. write the following command:

sudo apt-get install openjdk-7-jdk

3. give your password (it will not be displayed on the screen)

4. Say yes to download the installation file

5. That's all you need. Enjoy coding with java



Hello everyone this post deals with the installation of a Java development environment on a Microsoft Windows PC.

Following are the steps involved:

1. Go to

2. Download the latest JDK versionhttp://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html


3. Double click the downloaded file and follow the installation instructions.

4. That's all you need, enjoy programing with java.