0
How does it look like a simple getString method? Could you write me a simple example?
I use out.println for this. It looks like: public void showMe() { out.println("The result is: " + getSomething() + getAnotherthing()); } ...but I heard getString method is better.
2 Answers
+ 1
if you are looking for another way to output a string, you can also use printf()
var s = System.out;
s.printf("The result1 is: %d (result2 is: %d)\n", getSomething(), getAnotherthing() );
or String.format() - if you want only string without output it.
%d is for int values
\n for end of line
for details look java.util.Formatter
0
Thank you zemiak! đ Generally I use method with "return" when I want some kind of result. Like 5+5 return 10. String with return... For me, that was strange đ