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?

Recommended Answers

All 2 Replies

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);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.