Converting lowercase to uppercase

Thread Solved

Join Date: Feb 2008
Posts: 3
Reputation: ineedhelp09 is an unknown quantity at this point 
Solved Threads: 0
ineedhelp09 ineedhelp09 is offline Offline
Newbie Poster

Converting lowercase to uppercase

 
0
  #1
Feb 10th, 2008
Hey everyone,

I'm new at this.. so please bear with me.

Anyway, I'm really confused.

I'm supposed to convert the first character of the String firstName to upper case.

Problem is... I have no idea how to

I've done so much research and reading and still nothing.

Please help me.

Thanks in advance!

This is my code;

public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {

char firstSymbol;


// First and Last Name

String firstName="mickey";
String lastName="mouse";
System.out.println(lastName + "," + firstName);
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 55
Reputation: WhYuLoOkIn is an unknown quantity at this point 
Solved Threads: 3
WhYuLoOkIn's Avatar
WhYuLoOkIn WhYuLoOkIn is offline Offline
Junior Poster in Training

Re: Converting lowercase to uppercase

 
0
  #2
Feb 10th, 2008
Check out the java API: http://java.sun.com/j2se/1.4.2/docs/...Character.html

If you still can't figure it out let me know.
Last edited by WhYuLoOkIn; Feb 10th, 2008 at 10:54 pm.
Doing what they say couldn't be done!!!!
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 3
Reputation: ineedhelp09 is an unknown quantity at this point 
Solved Threads: 0
ineedhelp09 ineedhelp09 is offline Offline
Newbie Poster

Re: Converting lowercase to uppercase

 
0
  #3
Feb 10th, 2008
Thank you for your reply.
I figured out how to do it using the replace method. However, now I'm asked to do it using the variable firstSymbol.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 55
Reputation: WhYuLoOkIn is an unknown quantity at this point 
Solved Threads: 3
WhYuLoOkIn's Avatar
WhYuLoOkIn WhYuLoOkIn is offline Offline
Junior Poster in Training

Re: Converting lowercase to uppercase

 
0
  #4
Feb 10th, 2008
Well if you use the replace method you will have to hard code your code. Which is ok if you know what the string variable contains, In a case where you don't know, this will not be good. So It is probably good if you get familiar with the toUpperCase method in the Character class.

Here is an example how to use it:
  1. String unknown = " java";
  2.  
  3. //charAt gets the first character in string and upperCase converts it to uppercase
  4. //then I add the uppercase J to the rest of the String with substring starting at the second
  5. //character in the string java, so basically: J + ava -> Java
  6.  
  7. unknown = Character.toUpperCase(unknown.charAt(0)) + unknown.substring(1);
Doing what they say couldn't be done!!!!
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 3
Reputation: ineedhelp09 is an unknown quantity at this point 
Solved Threads: 0
ineedhelp09 ineedhelp09 is offline Offline
Newbie Poster

Re: Converting lowercase to uppercase

 
0
  #5
Feb 10th, 2008
Thank you! Works great, But does it incorporate the firstSymbol variable I told you about? =/
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 7
Reputation: edchabz is an unknown quantity at this point 
Solved Threads: 0
edchabz edchabz is offline Offline
Newbie Poster

Re: Converting lowercase to uppercase

 
0
  #6
Feb 11th, 2008
Have you heard of unicode? In unicode each character has a corresponding number. A-Z corresponds with 65-90, while a-z corresponds with 97-122. In order to make the letter j into a capitol J you would convert the j into unicode, subtract 22, and convert back to letters, but I don't remember how to do it and I forgot to write it down in my notes LOL so just search around for unicode and it should help you.

PS I am a student and I just learned about this last week so if I'm wrong please feel free to correct me... I am trying to solve my own problems and thought I'd look around and see what else was here lol
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 2
Reputation: webmstr is an unknown quantity at this point 
Solved Threads: 0
webmstr webmstr is offline Offline
Newbie Poster

Java String Operations

 
0
  #7
14 Days Ago
Hi guys, converting uppercase or lowercase strings in java is so simple but if you wanna see a more complex application you can look at here...

There is a function that makes first letters of words, sentences or lines Uppercased in JAVA.
<URL SNIPPED>Uppercasing First Letters

This may be useful for learning more string operations.
Last edited by peter_budo; 14 Days Ago at 4:13 am. Reason: Keep It On The Site - Posts must contain actual content and substance and cannot simply be external links.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC