This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "substring" Watch "substring" New topic


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

Joined: Jan 05, 2005
Posts: 7

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,
smitha mano
Ranch Hand

Joined: Sep 26, 2005
Posts: 70
thanks very much
subject: substring
Similar Threads
WA #1.....word association
Cant use object from another class
Posting to bump up my count...
Text box value is not being completely filled with request attribute
The x900 effect ?