Tuesday 27 November 2012

PROGRAMS ON ARRAY2

NOTE:-
       we cant use {} to announce arrays where ever we want i.e if we declare an variety at one place and initialize it at another place then we cant use {} for initialization. In this scenario we have to use the 'new' proprietor.

consider the following example
       classification Ademo5
         {
             Series s1 ] = {"abc","xyz"};
             int i1 [];
             group set gap main (String args [])
               {
                     Ademo5 a1 = new Ademo ();
                    // a1.i1={1,2,3}; // this is disallowed associate notice above
                    a1.i1=new int [6]; // this is permitted
                    int j[] = new int [0];// this is disallowed because sizing is not // defined
                  /* Any non-negative integer can be described as the size*/
                  int j[] = new int [0]; //An variety with zero elements
                   System.oy.println (j); // cope with of variety product j will be printed
                   System.ot.println (j.length); // 0 printed
                   // System.out.println (j [0]); // error because variety has no // elements
                   Series S1[] = new Series [0];
                   Series S1 [] = {};
               }
         }


NOTE:

     When JVM telephone cellphone calls the main strategy it finishes main strategy as a range when we get in touch with the main strategy JVM finishes it as a function

    whether JVM telephone cellphone calls the main strategy or we get in touch with the main strategy the corresponding discussion have to be the main strategy.
    now the question is when JVM telephone cellphone calls the main strategy. What is that conversation ?

HINT: Definitely the conversation is not zero. Then what is it ?

NOTE:
       We can get in touch with main strategy of one classification pc computer file from the main strategy of another classification pc computer file by going zero as conversation . But JVM cannot get in touch with main strategy of a classification pc computer file by going zero as an conversation.

HERE COMES THE CONCEPT OF COMMAND LINE ARGUMENTS.
  The command range discussion the conversation which are accepted along with the java command on the command prompt.

class ArgDemo
 {
    group sdtatic gap main (staring args [])
     /* ( we can offer any name which is not a key phrase. It is the physical work out to use args, but not necessary.)*/
     {
         System.out.println (args.length);
         if (args.length>0)
           {
               System.out.println (args[args.length-1]);
            }
        }
}


C:/> javac ArgDemo.java
java ArgDemo 10 a "bbb" 20.5f "nit"

OUTPUT:-
5
nit

No comments:

Post a Comment