Monday, 24 April 2017

New Update of JAVA 

Java 9 will be coming this Year and we are much excited(Talking about the Programmers here). So one of the best feature that I found is :
Jshell

So what is Jshell?
Let's say that you have to run a few lines of Code, like adding two numbers. So, for that you have to write all that code for that small work. But the jshell is an extra feature will be added in the new Update so you don't have to install it separately. This will really save Time.

What's your favorite Feature?Comment

Friday, 21 April 2017

Why is Java more safe than C++?

It's one of the questions we think everytime, whenever we are asked about it. So, the simple answer that is due to pointers.
Now how is this this the shortest Answer? Think about it that what pointers do? They create loop holes in a language.
But How?
A  pointer is a programming language object, whose value refers to (or "points to") another value stored elsewhere in the computer memory using its memory address.(This definition is from Wikipedia).

Now My own definition: A pointer is an object which points to the value and address of the other object in the Program. We can change the value of that variable through pointer.(Can even find out the address).

So by having the ability to point to the other variable it decreases the security level in Programming Languages.  So Java doesn't have Pointers. That's how it becomes More safe because everything is running inside the JVM. 

Friday, 7 April 2017

Does Java can have more than on main method?

Well, depending on the type of the question I can say that yes we can define more than one main method in a Java Program.
But the difference will come when you will give the name to your Program, then the class having that name should have at-least one main method.

Example:

class Test1{

public static void main(String[] args)
{
System.out.println("This is Test 1");
}
}

class Test2{

public static void main(String[] args)
{
System.out.println("This is Test 2");
}
}

Explanation: 
Now at the end of the Program, you have to just save it with the class name(Let's say Test1 in above code), which you want to be executed first.
Like: Test1.java

Tuesday, 4 April 2017

Is there "goto" in Java?

Yes and No, I think both will be correct But the absolute answer is "Yes, there is goto in Java".(Not for usage but it is present and reserved). Now you might be wondering, How?

Let's understand this with an Example:

import java.io.*;
import java.util.*;
import java.lang.*;

class Test6{

public static void main(String[] args) throws IOException {

starting_point:

for (int i=1;i<10 ;i++ ) {

System.out.println("Now the Value of Number "+i);

if (i=9) {
goto starting_point;

}

}

}


Explanation: 

Now on Compiling this errors occurs,

and that is Because the goto is reserved keyword. True the goto is there  but it is not available to be used in the Program. The reason is that if in case it were to be added to a later version of Java and if the Programmer had used that word  in his Program, then the Program would break. So the Program will not even execute.

There is another option instead of using goto, you can use labels(with break).