How do I change the ASCII value of the character? It seems to give me the values but I don't know how to change them. I am not sure how to do it right.

public void toUpperCase(){
		//	if ((ch >='a')&&(ch <='z'))
		//		return(char)(ch-32); // Explicit
		//	return ch;
			
			for(int i = 0; i < theString.length; i++){
				System.out.println("i="+i);
				
				if (((int)theString[i] >=97)&&((int)theString[i] <=122))
				{ theString[i]= (int)theString[i]-32;
				}
				System.out.println("j="+(int)theString[i]);
				 // Explicit
			}
		}

Recommended Answers

All 2 Replies

Never mind fix theString[i]= (char) (theString[i]-32);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.