• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

char.. play

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
Can any1 pls.. explain 2 me what should be the right way to use the special char. supported by java....
special characters like:
'\n' for new line
'\r' for return
'\t' for tab
'\f' for formfeed // by the way... wht. is this?
'\b' for backspace
My q. is how can we use these in our progs ?
THANKS IN ADV.
<marquee> Ratul Banerjee </marquee>

[This message has been edited by ratul banji (edited March 23, 2001).]
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
like this:
System.out.println("A\nB\rC\tD\fEEE\b");
check the result, and letter 'B' will not show on the screen
because '\r' have move the cursor to the first position of current line then it print 'C'.
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,
u just need to place these special codes in the
System.out.println(//here)
within " ", and thats all.
Like
System.out.println("Ratul\n is a javaranch member");
u will see that Ratul will be one line above the other part.
 
ratul banji
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks to both of u.
But...I am not clear enough..with '\f' for FormFeed.
Can u explain it more specifically...pls.
Thanks ..1ce again.
Regds.
<marquee> Ratul Banerjee </marquee>

 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These are the escaped forms of ASCII "control codes" - You can't enter them directly because they would interfere with the compiler reading the source code. The compiler converts them to the real control codes when it creates a String or char literal.
form feed is the control code that causes a printer to advance to the next form - typical use would be printing invoices, etc. especially with continuous feed paper forms.
Bill

------------------
author of:
 
So you made a portal in time and started grabbing people. This tiny ad thinks that's rude:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic