FAQ Database Discussion Community


Algorithm output to length starts new line

java,arrays,integer,string-formatting,system.out
I am trying to format the output from what I have written to display a list of primes (Eratosthenes) to a certain number results per line. Do they need to placed into an Array to accomplish this? I have not come across a way to implement their division besides .split("");,...

Return statement for a string array giving strange result

java,arrays,string,return,system.out
I am creating a String array and using System.out.println to print the values in the array. All good and works as expected, returning [South Africa, England] but the code won't compile unless I include a return statement, but the return statement just dumps out a load of garbage "[Ljava.lang.String;@85bdf6". Is...

How to get the value which I sent via System.out.println?

java,system.out
Sorry I searched a lot but could not find an answer to it. If there is , I a apologize and please let me know. If I have sent an value via System.out.println or .print is there any way to get it ? I mean after sending get all values...

Reading System.Out

java,system.out,system.err
So, what I want to do is basically filter everything that is passed through System.out and System.err, is it possible to apply a filter of some sort or to create my own OutputStream to divert System.out with, and then process it normally? Edit for clarity: To clarify, I need to...

System.out.print . How do you get the printed output to be numbered? (Java)

java,output,system.out
So assuming I am printing out a huge record of 500 staff members. And upon printing out the record I would like it to look something like: 1. Matthew J. $USD 28.404 2. Donna M. $USD 43.254 3. Jordan D. $USD 15.532 4. 5. 6. 7. and so on...... However...with...

The Result is not coming in correct format in Java code

java,string,algorithm,stringbuilder,system.out
Here in I want the Stringbuilder to append the result of each calculation. But its not coming in the correct format. In the code I am trying to find all the comman factors of two numbers and getting the kth value. But my result is not coming in the expected...

What is the benefit of using System.out.print over System.out.printf?

java,printf,system.out,printstream
I have a question similar to Is there a good reason to use "printf" instead of "print" in java?. That question asks and is answered about the benefits of using System.out.print over System.out.printf. I am curious about the benefits to using System.out.print over System.out.printf in the first place. In my...