Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Closed Thread
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old August 23rd, 2002, 07:04 AM
peter83 peter83 is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 19 peter83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
change first character to uppercase

1) i need to know how to change a String first character to uppercase.

2) i also how to change all characters to lower case.

3) i also need to know how to replace a space with underscore
eg " " to "_".

Reply With Quote
  #2  
Old August 23rd, 2002, 03:55 PM
tron's Avatar
tron tron is offline
SwollenMember
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Location: the master control
Posts: 234 tron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 44 m 46 sec
Reputation Power: 9
if you are on unix use sed: here is a simple example of how to change any letter a with b in some file

sed 's/a/b/g' somefile


once you can figure out the regular expression it should be easy. if you need help with regex let me know.

Reply With Quote
  #3  
Old August 23rd, 2002, 10:55 PM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
Take a look at the docs for java.lang.String: http://java.sun.com/j2se/1.4/docs/a...ang/String.html

Reply With Quote
  #4  
Old August 24th, 2002, 03:45 PM
CharlesBell CharlesBell is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Vicksburg, MS
Posts: 7 CharlesBell User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
/* Example.java
*/


public class Example{

public static void main(String[] args){
Example example = new Example();
example.test();
}

public void test(){
String someString = "la la la la la la la";
/* 1) i need to know how to change a String first character to uppercase. */
String string1 = someString.substring(0,1).toUpperCase() + someString.substring(1);
/* 2) i also how to change all characters to lower case. */
String string2 = someString.toUpperCase();
/* 3) i also need to know how to replace a space with underscore
eg " " to "_". */
String string3 = someString.replace(' ','_');
System.out.println(someString);
System.out.println(string1);
System.out.println(string2);
System.out.println(string3);
}
}

Reply With Quote
Closed Thread

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > change first character to uppercase


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway