|
Adding (+) a string to an integer (or float, or double, etc) will produce a string with that number in it... There is a couple of ways to do what you are describing... this is the simplest way: String foo = "B0000"; int bar = 1; String foobar = foo + bar; //This will produce your example string //Another way to do the same thing String foobar = "B0000" + 1; //Then there is the DecimalFormat which would be better for use in a loop //where you need to generate a bunch of similar strings like you are //describing. java.text.DecimalFormat formatter = new java.text.DecimalFormat("B00000"); //formatter.format returns a String for(int i = 0; i < 100000; i++) System.out.println(formatter.format(i)); // Output would look like this: // > B00000 // B00001 // ... // B99998 // B99999 Hope that helps. Dan Feather Silhouette/PinPoint R&D Programmer Jack Henry & Associates, Inc. dfeather@xxxxxxxxxxxxx -----Original Message----- From: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of RPower@xxxxxxxxxx Sent: Thursday, April 21, 2005 2:01 PM To: Java Programming on and around the iSeries / AS400; RPG programming on the AS400 / iSeries Subject: MOVE functionality in Java? I realize this is more pertaining to Java. But RPG programmers might have a good answer as well, so I sent it to both lists. Sorry. I want to build a string such as "B00001" in Java using a string and an integer. Is this possible? I know if it were RPG I'd use a MOVE function. Any ideas? TIA. And sorry David. Ron Power Programmer Information Services City Of St. John's, NL P.O. Box 908 St. John's, NL A1C 5M2 Tel: 709-576-8132 Email: rpower@xxxxxxxxxx Website: http://www.stjohns.ca/ ________________________________________________________________________ ___ Success is going from failure to failure without a loss of enthusiasm. - Sir Winston Churchill -- This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) mailing list To post a message email: JAVA400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/java400-l or email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/java400-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.