WHAT IS BEST WAY TO DECLARATION A VARIABLE ? FOLLOW BELOW EXAMPLE?

marcel ethan

Total Post:105

Points:735
Posted by  marcel ethan
Java 
 1079  View(s)
Ratings:
Rate this:
Hi Expert! 

Example:

String one="One", two="Two", Three="Three";
(or)

String one="One";
String two="Two";
String Three="Three";

See, above e.g which one is best way in real time? what is difference both us? i am using 1st one it is save the class file memory. but all programmer use 2nd one.why there was use 2nd I did not understand?

Please give proper solution!
Thanks in advance! 
  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: What is best way to declaration a variable ? follow below example?

    Hi Marcel!


    There is no difference. Compiler will do it in the best way, so in byte code you would have always (in both cases):

       // access flags 0x0
       Ljava/lang/String; one

       // access flags 0x0
       Ljava/lang/String; two

       // access flags 0x0
       Ljava/lang/String; Three

    Going this way, use what is more appropriate in your project. Don't care about the memory!

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!