Reputation:
for (int numToCheck = start; numToCheck < numSteps*increment + start;
numToCheck += increment)
{
System.out.println(numToCheck+"\t");
String tekst = getStringFromFile(textfile, numToCheck);
double beg1 = System.currentTimeMillis();
for(int i = 0; i<trials; i++) {
BasicDocument doc = new BasicDocument(tekst);
doc.getFleschScore();
}
double time1 = System.currentTimeMillis() - beg1;
System.out.println(time1+"\t");
double beg2 = System.currentTimeMillis();
for(int i = 0; i<trials; i++) {
EfficientDocument doc2 = new EfficientDocument(tekst);
doc2.getFleschScore();
}
double time2 = System.currentTimeMillis() - beg2;
System.out.println (time2);
This is the code I'm running, and the results are printed in new lines, not separated by tabs (\t).
What am I not understanding?
Also, anything else you can give me advice about, I have started programming just recently, does the code look good?
Upvotes: 0
Views: 442
Reputation: 11999
Use
System.out.print()
not
System.out.println()
From the doc of println()
Terminates the current line by writing the line separator string. The line separator string is defined by the system property line.separator, and is not necessarily a single newline character ('\n').
Upvotes: 3
Reputation: 2287
Use
System.out.print()
with \t
\t
will add a tab and print()
method will print on the same line so you will be
having your output separated by tab.
Upvotes: 0
Reputation: 201517
Change
System.out.println(time1+"\t");
to
System.out.print(time1+"\t");
println
always adds a newline.
Upvotes: 1