• Post Reply Bookmark Topic Watch Topic
  • New Topic

Charcter  RSS feed

 
Sunil Shivarathri
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can any one tell me the logic for this i want to print Aa,Bb..............Zz using java
 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sunil,
There is a ASCII character table in computer science .. Please read this : ASCII

Try this :



Thanks ,
Satya
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
S Majumder, please go here, where you will read this:-
We're all here to learn, so when responding to others, please focus on helping them discover their own solutions, instead of simply providing answers.
It does not help to provide complete solutions, and I would probably have deleted that had I seen it earlier.
Please don't provide complete answers like that.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A few minutes ago, I wrote:. . .
Please don't provide complete answers like that.
Least of all when the answer is as poor as what you posted.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch Sunil Shivarathri.
 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Least of all when the answer is as poor as what you posted.


Hay Campbell I am not getting , could explain this ..

Satya
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It doesn't do what is required; it prints
Aa
Bb
Cc

Zz
when the requirement was AaBbCc…Zz.

The double declaration is pretty poor style. If you have the details of one letter, you can get the other from methods in the Character class.
Why are you using ints when you want chars? Then you have to perform a narrowing conversion with a cast, which is always a bad sign.
Why are you initialising the values to number literals when you could use char literals. The numbers are error‑prone and not self‑explanatory. Writing 'a' and 'z' would be self‑explanatory.
Why are you using multiple print statements when you could append the chars to a String Builder? You might not notice the few milliseconds it takes to print 26 lines, but if you have multi‑threading and want to print 26000 lines or 26000000 you will notice the delay.
 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:It doesn't do what is required; it prints
Aa
Bb
Cc

Zz
when the requirement was AaBbCc…Zz.

The double declaration is pretty poor style. If you have the details of one letter, you can get the other from methods in the Character class.
Why are you using ints when you want chars? Then you have to perform a narrowing conversion with a cast, which is always a bad sign.
Why are you initialising the values to number literals when you could use char literals. The numbers are error‑prone and not self‑explanatory. Writing 'a' and 'z' would be self‑explanatory.
Why are you using multiple print statements when you could append the chars to a String Builder? You might not notice the few milliseconds it takes to print 26 lines, but if you have multi‑threading and want to print 26000 lines or 26000000 you will notice the delay.


First of Campbell , its hardly a difference of printing same / next line (hope you understand !!! ). Next I tried to give him (Sunil) the simple solution rather start think about Thread , Builder,Narrow or border conversion etc etc ...
Yes the points (you mentioned) comes into picture when we consider performance .

And finally programming / coding is an ART !!! We can write a code by different ways .Hope this you understand ..

Thanks,
Satya
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!