This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes substring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "substring" Watch "substring" New topic
Author

substring

smitha mano
Ranch Hand

Joined: Sep 26, 2005
Posts: 70
i have EMP database in a field history contains 500 charactes.
i want to display first 125 characters
How to do this using Java?
Ravi Shankar R
Greenhorn

Joined: Jan 05, 2005
Posts: 7
Hi,

public class DemoDisplay {

public static void main(String[] args) {
// Let this be the output String retrieved from the database EMP
String word = "123456789";
int worldLenght = word.length();
int end = worldLenght - (worldLenght - 3);
// Would retieve the first 3 characters of the String word.
String sub = word.substring(0, end);
System.out.println("sub :: " + sub);
}
}

I hope this helps you ......

With Regards,
Ravi.
smitha mano
Ranch Hand

Joined: Sep 26, 2005
Posts: 70
thanks very much
 
 
subject: substring