• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how does this code make beep sound

 
Naufal Mohamed
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everybody
i'm new to this forum and a novice for java.
i'm delighted about this forum where beginners like me can clarify even a simple problem in java.
hope that i too get the fullest support from you guys.thank you
heres my problem:
for (i=0; i<10; i++)
System.out.print((char)7);
above for loop makes the computer to beep.
how does this happen? is this a standard method to
make the computer beep?
[ January 14, 2003: Message edited by: Naufal Mohamed ]
 
Marilyn de Queiroz
Sheriff
Posts: 9061
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(char)7 is equal to Ascii 0007 which is a control character. Letters/numbers don't begin until Ascii 28 or so. Control characters do special things. Form feed, carriage return, line feed, bell (which is the one you've discovered), and more. Most people don't use computer beeps anymore. Since speakers have come into more common usage, they use .wav files instead to get your attention.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch, Naufal!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic