Java Installation and hello world. - Neuroon Networks

Breaking

Sunday, February 25, 2018

Java Installation and hello world.


         What is java?

                    Java is a programming language and computing platform first released by Sun Microsystems in 1995. There are lots of applications and websites that will not work unless you have Java installed, and more are created every day. Java is fast, secure, and reliable. From laptops to data centers, game consoles to scientific supercomputers, cell phones to the Internet, Java is everywhere. ava code can be run on multiple platforms e.g. Windows, Linux, Mac/OS etc.

     To follow these tutorial i hope you guys have installed the JDK in to your machines as well as the Netbeans.


             so lets start our first project.

First of all launch in to the netbeans. Then go to File ->New project.


 Then you have to select the Java in the categories and and Java Application in the Projects and press Next.


Give the name of the project as MyFirstJavaPrograme (Use the camel notation when writing the project name Camel case (stylized as camelCase or CamelCase; also known as camel caps or more formally as medial capitals) is the practice of writing compound words or phrases such that each word or abbreviation in the middle of the phrase begins with a capital letter, with no intervening spaces or punctuation. ) and click finish.


Now you will get a interface like. In here 
       
           public class MyFirstJavaPrograme{    <------ This is your class
                     
                        public static void main(String[] args){ <----- Main method.



                      }
         }

what is a class in java?

             According to the java Documentation In the real world, you'll often find many individual objects all of the same kind. There may be thousands of other bicycles in existence, all of the same make and model. Each bicycle was built from the same set of blueprints and therefore contains the same components. In object-oriented terms, we say that your bicycle is an instance of the class of objects known as bicycles. A class is the blueprint from which individual objects are created.
The following Bicycle class is one possible implementation of a bicycle:
 
class Bicycle {

    int cadence = 0;
    int speed = 0;
    int gear = 1;

    void changeCadence(int newValue) {
         cadence = newValue;
    }

    void changeGear(int newValue) {
         gear = newValue;
    }

    void speedUp(int increment) {
         speed = speed + increment;   
    }

    void applyBrakes(int decrement) {
         speed = speed - decrement;
    }

    void printStates() {
         System.out.println("cadence:" +
             cadence + " speed:" + 
             speed + " gear:" + gear);
    }
}
 
 
What is main method in java?
 
  The main method in the Java language similar to the main function in C and C++. When the 
Java interpreter executes an application (by being invoked upon the application's controlling 
class),it starts by calling the class's main method. The main method then calls all the other 
methods required to run your application.
 
 
Same like other programing languages lets begin with the Hello world.  
 


   
 Type the System.out.println("Hello world"); in the main method and try the output 
(press the f6 or click the play/run button).


      The print Statement in java is - System.out.print() / System.out.println(). In here System.out.println() takes the cursor to the next Line while System.out.print() keeps the cursor in the same line.


 
For more-

          System.out.println is a Java statement that prints the argument passed, into the System.out which is generally stdout.
  1. System is a Class
  2. out is a Variable
  3. println() is a method
System is a class in the java.lang package . The out is a static member of the System class, and is an instance of java.io.PrintStream . The println is a method of java.io.PrintStream. This method is overloaded to print message to output destination, which is typically a console or file.
the System class belongs to java.lang package.




                                  See you guys in Next Tutorial.
 
 
 



No comments:

Post a Comment