• Post Reply Bookmark Topic Watch Topic
  • New Topic

nPrint method in JAVA  RSS feed

 
Rd Dari
Ranch Hand
Posts: 214
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I am so confused with nPrint method in java.Please help me.


Thanks in advance...
 
Paul Clapham
Sheriff
Posts: 22841
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But nPrint isn't a method of any of the classes in the standard Java API. So it must be a method of some other class. Which means we know nothing except that you're asking about a method named "nPrint". Please read this: TellTheDetails and then post some information about just what is confusing you.
 
Rd Dari
Ranch Hand
Posts: 214
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am facing this question but I do not understand this.....

What is k after the following block executed?
{
int k = 2;
nPrint("A message", k);
}
 
Rd Dari
Ranch Hand
Posts: 214
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is k after the following block executed?
{
int k = 2;
nPrint("A message", k);
}

The output of this:
k is not defined outside the block.

So I am confusing.......
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code. It will highlight your code and make it easier to read. It probably will also increase the number of people helping you.

Try to TellTheDetails in advance. That way we don't have to ask you for more information and nobody is wasting time.

The keyword is scope. If you declare a variable then it has a scope. It is visible (in scope) between the two brackets it is declared in. After that it's no longer in scope and can't be accessed. So after your method has run the variable k is out of scope and can't be reached.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!