• Post Reply Bookmark Topic Watch Topic
  • New Topic

Core java(static block example)

 
haripriya vedula
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class StaticDemo {

public static void main(String[] args) {
System.out.println("java");
}
}

Output should be "Sun java programmer" without changing main method.

I know to use static block but if i use

static{
System.out.println{"Sun java programmer"}
}

i am getting output as "sun java programmer" and "java".

thanks in advance
 
Devaka Cooray
Marshal
Posts: 5174
489
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, this isn't belonging to WebServices? Please CarefullyChooseOneForum for asking questions
Regarding your question, I don't think there is a way to get the desired result without changing the main method.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!