lundi 20 avril 2015

String initialization confusion in java

i was trying to call the main function inside the main function i have tried the following code and got successfully compiled code.

class test
{
  static int i = 0;

  public static void main(String args[])
  {
    String asda[] = {"!2312"};

    if (++i == 1)
      main(asda);
  }
}

But the error occurs in case of the following code:

class test
{
  static int i = 0;

  public static void main(String args[])
  {
    if (++i == 1)
      main({"!2312"});
  }
}

this made me so confused. the confusion is that String array initialization is done like String A[]={"asdf","Asdf"); then why is it giving error in second case. I m using java 8u40. please solve my problem

Aucun commentaire:

Enregistrer un commentaire