• Post Reply Bookmark Topic Watch Topic
  • New Topic

where could i search to find about systemout a method?  RSS feed

 
ekte spiriopoulos
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to system.out.println the whole method .How could i do that?example or a link to read ? thanks
 
Liutauras Vilda
Sheriff
Posts: 4928
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't think it is correct to say "to print whole method". What you can print, is returned value by method (if method returns one). Example:

So you can print like this:
Output would be 7.

Or, you can assign returned value to a variable and then print:
 
Tim Cooke
Marshal
Posts: 4051
239
Clojure IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't really understand the question. Can you explain it a bit clearer?

For a start: define "the whole method"?
 
ekte spiriopoulos
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Cooke wrote:I don't really understand the question. Can you explain it a bit clearer?

For a start: define "the whole method"?
1) i want only to system.out a method (returning the whole array )

2) can i call a method inside in another method?
 
Liutauras Vilda
Sheriff
Posts: 4928
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1.
2. Yes.
 
Campbell Ritchie
Marshal
Posts: 56595
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ekte spiriopoulos wrote:. . . i want only to system.out a method (returning the whole array ) . . .
That does not make sense. Most of the methods of System.out do not return anything.

This where you can search: Go into the Api documentation and find the System class. You will find it has a static member called out. Click on that and it will tell you what type out is. Click on the class name and you can find what sort of methods that class has. It is a little easier for System.out because there are several methods shown under “See Also:” and maybe you will find what you are looking for there.
can i call a method inside in another method?
You can only call methods inside other methods (or constructors, etc). You can pass the return value from a method to another method, assuming it is the correct type; Liutauras has shown you two examples of how to do it. He has even shown you the (probably) easiest way to display an array. You would need to import java.util.Arrays; first.
 
ekte spiriopoulos
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:. . .
On his example he could write this on the end of his line : return Array[]; is that good?
 
Liutauras Vilda
Sheriff
Posts: 4928
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ekte spiriopoulos wrote:On his example he could write this on the end of his line : return Array[]; is that good?
Show your suggested way in code example, as your worded statement doesn't make sense without any context around.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!