0
System.out.println("You are currently at " + n);

I just want to color the 'n' in the output, n is an int which is already initialized. Is there a way to do it?

sleske
  • 81,358
  • 34
  • 189
  • 227
velvet
  • 1
  • Print (without println) the "You are currently at" alone, then print the n with the desired color (Not all terminals support colors). Note the you can use `System.err.println` to print it in red color (in Eclipse for example). – Maroun May 01 '13 at 07:35
  • @MarounMaroun I don't think the `System.err` advice is good. It may happen to look correct in Eclipse, but in a normal console it will not work properly at all (especially if stderr is piped elsewhere). – Duncan Jones May 01 '13 at 07:58
  • @DuncanJones You're right. I sometimes use it in eclipse to better see important outputs. I thought this might help him. – Maroun May 01 '13 at 07:59

1 Answers1

0

Search around for "color control characters". Here's one link: http://www.linuxgazette.net/issue65/padala.html

iluxa
  • 6,941
  • 18
  • 36