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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

how to print ascii characters on the screen

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
hi there, i need to write a program which i can enter the first desired ascii character, and the last, and the program prints the list to the screen, but i dont know how to get started, do the characters have a numerical relation, please help Bob
 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Yes, characters can be interchanged with numbers. ASCII is basically a mapping for doing just that. The character 'A' is 65, and 'B' is 66, for example.

If you write

System.out.println(65)

you see the number 65, but if you cast the number to a "char", then you'll see the character 'A':

System.out.println((char) 65);


Note that Java doesn't actually use ASCII -- it uses Unicode, which is a (huge) superset. For your purposes, this might not matter.
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Since characters are really represented as numbers under the hood, this means that you can "count" with them. So to print out every character in a given range, it sounds like a loop of some kind would be helpful. Does this give you any ideas where to start?

Once you have made a crack at working on this, post some of your code and we can help you refine it. Also, if you have any compiler errors, post those along with some indication of which line causes each error.

Keep Coding!

Layne
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
hello, im new and i need help with something similar.[Deleted because what was posted was completely different. Please post your question again as a new thread.]
 
Sheriff
Posts: 67682
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
"freddie mercury", please check your private messages for an important administrative matter.

Also, please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the button on your post.
 
Marshal
Posts: 76888
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
And, "Freddy Mercury" please do not ask questions unrelated to the original topic. So as to allow Bob Holland his thread back, I am afraid I feel obliged to delete most of your posting.
 
Bartender
Posts: 2908
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

Bob Holland wrote: to the screen


I hope you are indeed referring to the command prompt.

Bob Holland wrote:do the characters have a numerical relation


yes, every character is represented by a numercial value
eg:
A = 65 and a= 97

you should use a char variable if you want the benefits of printing and iterating them.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please note that this is a topic from 2005. The poster is most likely not still waiting for an answer.
 
Campbell Ritchie
Marshal
Posts: 76888
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

Jesper Young wrote:Please note that this is a topic from 2005. The poster is most likely not still waiting for an answer.

I hadn't noticed. Best to close the thread to avoid further confusion.
 
Arch enemy? I mean, I don't like you, but I don't think you qualify as "arch enemy". Here, try this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic