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?

9 Years
Discussion Span
Last Post by dreamer14

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..


Oo my bad reali should be at java forum. Anyway i maaged to solve it thx for the help.

String t122="AA0001";
char t22=t122.charAt(5);
String t32=String.valueOf(t22);
char t42=t122.charAt(4);
String t312=String.valueOf(t42);
String t4112=t312+t32;
int t412=Integer.parseInt(t4112);
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.