String

Thread Solved

Join Date: Sep 2008
Posts: 21
Reputation: dreamer14 is an unknown quantity at this point 
Solved Threads: 1
dreamer14 dreamer14 is offline Offline
Newbie Poster

String

 
0
  #1
Feb 8th, 2009
Hi iwould like to check if there is any function that allows me to take the last 4 char or a String? Or the 1st two char of a String? I require this because i require to have a auto increase product id. Example current productid stops at WA0059. When admin goes to add new product page, WA0060 should be filled into the productid box automatically. THis is to ensure the naming convention is consistent. Any suggestion how to implement this?
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 1,175
Reputation: stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light 
Solved Threads: 125
Featured Poster
stephen84s's Avatar
stephen84s stephen84s is offline Offline
Veteran Poster

Re: String

 
1
  #2
Feb 9th, 2009
This is more of a core java question, So it should have been posted in the Java forum.
Anyways take a look at the javadocs of the String and StringBuffer class you might find what you are looking for there, most probably it is the substring (1,2) menthod..
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."

"How to ask questions the smart way ?"
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 21
Reputation: dreamer14 is an unknown quantity at this point 
Solved Threads: 1
dreamer14 dreamer14 is offline Offline
Newbie Poster

Re: String

 
0
  #3
Feb 12th, 2009
Oo my bad reali should be at java forum. Anyway i maaged to solve it thx for the help.
  1. String t122="AA0001";
  2. char t22=t122.charAt(5);
  3. String t32=String.valueOf(t22);
  4. char t42=t122.charAt(4);
  5. String t312=String.valueOf(t42);
  6. String t4112=t312+t32;
  7. int t412=Integer.parseInt(t4112);
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