This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

creation of object for a class in static method

 
Chandra Bairi
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class Ex2 {
public static void main(int args) {
class Hii{
}
}
public static void main(String[] args) {
}
}
How can we create an object for a class in static method and the method has parameters to pass? any help please
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is your question "How can I create an instance of "Hii" from code in main(String[]) ? The answer is, simply enough, that you can't. Classes local to a method can't be constructed in any code outside that method; whether there are parameters, or whether the methods are static, have no bearing on the question.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic