wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes toUpper, toLower for chars Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "toUpper, toLower for chars" Watch "toUpper, toLower for chars" New topic
Author

toUpper, toLower for chars

Anthony Smith
Ranch Hand

Joined: Sep 10, 2001
Posts: 285
public static char letter(boolean isUpper)

{
char[] letters = {'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R' ,'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
double x = Math.random()*25;
if (isUpper==true)
return letters[(int)x];
else
{
char new_letter = letters[(int)x];
new_letter.toLowerCase('k');
return new_letter;
}
}

The toLowerCse will not work. Char cannot be de-refernced it says
Bill Krieger
Ranch Hand

Joined: Sep 27, 2001
Posts: 53
The variable 'new_letter' is a char primative. Primative values are not objects, they have no member variables or methods. Perhaps you meant to us the Character wrapper class? Perhaps...
new_letter = Character.toLowerCase( letters[(int)x] );
Colin Kenworthy
Ranch Hand

Joined: Aug 06, 2001
Posts: 88
Learn the difference between char and Character.
Learn the difference between a primitive type and an Object.
...then you should understand what's going on.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: toUpper, toLower for chars
 
Similar Threads
Polynomials and Hashing
need help
Programming Diversion 2b: Applying a hat
Language doubt
Can not find my error ? Help