JAVA Beginners Part 3

Running a program means telling the Java Virtual Machine (JVM) to “Load the class, then start executing its main () method. Keep running ’til all the code in main is finished.”

print vs println

print will keep printing to the same line while println will add a new line.

How JAVA can help you with your daily routine. Very funny example from Head First.

v1.jpg

New Program, New tools

String[] worldlistone = {“24/7″,”multi-tier”,”30,00 foot”}

// note, the S in String must be capital. This is String array. length of the string can be found using. Below statement will give the number of items in the array, which is 3. Also note JAVA arrays are ZERO based, which means they will start with 0.

int onelength = worldlistone.length;

//To generate random numbers you can use the below. What i noticed with few tries is that the type of random numbers generated this way is double and the value is always less than zero.

double rand = Math.random();

0.8931210621384496
0.14414548054221799
0.16660354544533518
0.19966040281191033
0.2842240591904822

Thought for the day

Javac is Java Compiler which Compiles your Java code into Bytecode.

JIT is Just In Time Compiler, is part of JVM which compiles given bytecode instructions to machine code at runtime before executing it .

JVM is Java Virtual Machine which Runs/ Interprets/ translates compiled Bytecode into Native Machine Code

In fact Bytecode is the reason JAVA is so fast. It is lightweight.

What does JAVA Compiler do?

JAVA is strongly typed language. Which means it can’t allow variables to hold data of wrong type. Compiler acts as a Police to stop that.Prevents access code violation , like trying to invoke private method.

References:

Head First Java 2nd Edition

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s