Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tab character question

 
Andrew Mcmurray
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am testing a parser object that is looking for strings in the following format and then put them in a map with the name as the key.

full name/temail/n. I want to create some test strings for the parser to test against. My question is should I manually put the tab in my test strings like String test = "My Name email@me.com'\n'"; or put the tab character in like String test ="My Name'\t'email@me.com'\n'"; or does it make a difference?

Thanks,

AMD
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String hello = "hello\tworld";
 
Andrew Mcmurray
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great thanks!

AMD
 
Andrew Mcmurray
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
one more you have to put the \t in single quotes right?

String test="Hello'\t'World";

Thanks,

AMD
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Give it a try without:

System.out.println("Hello\tworld!");
 
Andrew Mcmurray
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that the same for the new line char too?

Thanks,

AMD
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup, see escape characters. Find yourself a good Java syntax reference book; it will be well worth your time.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic