println

Scala extra parentheses printout

Hi, I wrote my first sample scala program and it looks like this: def main(args: Array[String]) { def f1 = println("aprintln") println("applying f1") println((f1 _).apply) println("done applying f1") } The output is applying f1 aprintln () done applying f1 Can someone explain why the extra () appears? I thought j...

JSP: where system.out.println prints ?

Where does tomcat puts the System.out.println output ? i'm not interested in OUT.println, i'm using a system that use system.out to log issues, like login sucess/fail, and i need to look to that generated "log". tnx!! ...

Java - Is it possible to print text that can be edited by the user (for console programs)

Say I allow the user to edit something, like the phone number in an Address Book (actually, that's exactly what I'm doing). Is there something that I can add to println that will allow me to insert a variable to display as fully editable text? The assignment that I'm doing this for doesn't actually call for this, but I think it would be ...

Java: system.out.println concatenating something within a string (really easy question)

I want my output to be Candy[1]. counterInt = 1 But my compiler isn't taking this code: System.out.println("Candy["+counterInt"]"); What can I do to have this variable appear within the string Candy[]? Candy[] is not an array, it's a string. ...

Can I have IO exception when I create a server socket in Java?

I have the following code: Socket clientSocket = null; try { clientSocket = serverSocket.accept(); } catch (IOException e) { System.err.println("Accept failed."); System.exit(1); } The code is taken from a java.sun.com. I have several questions concerning the above given short part of the code. Why do we want to catch an I...

Scala println in a for loop

The following Scala code does just what I expect it to - it prints each line of some_file.txt. import scala.io.Source val lines = Source.fromPath("some_file.txt").mkString for (line <- lines) print(line) If I use println instead of print, I expect to see some_file.txt printed out with double-spacing. Instead, the program prints ...

Why won't this println command start a new line?

Here's the relevant code: public static void printBoarders (Territory x) { int t = 0 ; int n = 0 ; for (int i = 0; i<x.borders.length; i++) { if (x.borders[i] == -1) t = i ; } for (int j = 0; j<x.borders.length; j++) { if (x.borders[j] == 1) n++ ; } Ter...

read ArrayList elements

Why it print the wrong output? ArrayList<String> loc = new ArrayList<String>(); This arraylist stored the value of: [topLeft, topLeft, topLeft, bottomLeft, topLeft, bottomLeft, topLeft, topLeft, Left, topLeft] the firs index 0 is = topLeft if(loc.get(1)=="topLeft") System.out.println("same") else { System.out.println("no...

Is there a way to print to the console in an Android app?

Can I run an Android app through the emulator and make it print strings to my computer's console? By console I mean the standard place you would expect to see a System.out.println() in a normal java application. So if you ran the java application from the command prompt then you will see the println()s in the command prompt or if you ran...

System.out.println not functioning

What are some scenarios in which java's System.out.println would fail to produce any output. I have a call to it inside of a method and sometimes when the method is called I get the println and othertimes I don't. Update: I am also using System.out.flush() after the println. Update: Thank you for the debugging help. It turned out a blo...

Should I use System.out.println() or something else?

I've been casually programming in Java for a while, but I still have a few burning questions on the fundamentals. I've heard that I should use System.out.println() to display data from some people, and others have given me different ideas (like PrintStream or something else). What's the best way to print to console in Java? ...

Remove blank lines that appear when writing to file (Java)

Hi guys. I have created a program which takes a text file full of 3 letter words and processes them, stores them in an array and then outputs to the build output in JCreator and then writes the same output to a file. Now, this program works fine, but when I print a lot of data - I get all of these blank lines inserted where there shoul...

Print in new line, java

Hi, I have following code : System.out.println(" | 1 2 3 4 5 6 7 8 9"); System.out.println("----------------------------"); System.out.println(""); I use println to create a new line. Is it possible to do the same using \n or \r? I tried to add \n to the second println statment and continue printing with the prin...