• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

int[]arg

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
the foll. methods are overloaded & it prints "main method with string[] args",what changes should be made so that it also prints "main method with int[]args "

public class Test16
{
static String str1="main method with String []args";
static String str2="main method with int[] args";
public static void main(String[]args)
{
System.out.println(str1);
}
public static void main(int[]args)
{
System.out.println(str2);
}
}
 
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello hema,
i've changed ur main(String []) function so that u can call the int version.
-) remember String version of main is the one that is called automayically by the java runtime when u run a program any other function u need to call explicitly
here is ur program with added code.
public class Test16
{
static String str1="main method with String[]args";
static String str2="main method with int[] args";
public static void main(String[]args)
{
System.out.println(str1);
int a[] = {1,2,3}; ///////********added
main(a); ///////********added
}
public static void main(int[]args)
{
System.out.println(str2);

}
}
 
reply
    Bookmark Topic Watch Topic
  • New Topic