Linked Questions

265 votes
24 answers
462k views

Here is the String, for example: "Apple" and I would like to add zero to fill in 8 chars: "000Apple" How can I do so?
Roy's user avatar
  • 2,681
296 votes
20 answers
558k views

I've seen similar questions here and here. But am not getting how to left pad a String with Zero. input: "129018" output: "0000129018" The total output length should be TEN.
jai's user avatar
  • 22k
4 votes
4 answers
16k views

Friends I have to impliment something in project, I found some difficulties, and is as follows: String name1 = "Bharath" // its length should be 12 String name2 = "Raju" // its length should be ...
Bharath A N's user avatar
4 votes
0 answers
5k views

I have a number, I want to pad this number with zero's in the beginning if the digits are less that 9 digits. currently if I have a number lets say: val num = "123" if I use padTo(9,"0") I will get "...
Joe's user avatar
  • 2,643
1 vote
3 answers
4k views

Possible Duplicate: How can I pad a String in Java? I have a stuation in which my method1() return the string of various size and I want to display the string in a fix space (say length 50 ...
Mike's user avatar
  • 1,909
1 vote
2 answers
840 views

I am trying to convert the following code which is in c# to java. And I am facing difficulty in converting it. Please can anyone suggest me a simple way to do it in Java. if (Password.Length <= 8)...
Farheen's user avatar
  • 239
-3 votes
3 answers
438 views

I am new to Java and I am trying make the hashtags to adjust to my text. For example, if I write "message hello, how are you?" I want it to print with capital letters and that the hashtags adjust ...
P. Jones's user avatar
0 votes
3 answers
193 views

I have an application that is creating a flat file for a legacy application. Something that is common when creating flat files is having to "pad" empty fields with either zeros or spaces. Today, the ...
Russ's user avatar
  • 2,007
0 votes
2 answers
100 views

I made a string into .trim(). I wanted to try and reverse it, but I can't seem to do it. For example, String a = " apple "; I did, a = a.trim(); such that: assert(a == "apple"); I want to ...
Blue Holliday's user avatar
1 vote
4 answers
121 views

Within a method, I have the following code: s = s + (items[i] + ":" + numItems[i]+" @ "+prices[i]+" cents each.\n"); Which outputs: Candy: 5 @ 50 cents each. Soda: 3 @ 10 cents each. and so ...
user2965623's user avatar
0 votes
1 answer
74 views

Hello I am trying to make a random Multiplication question generator with the answer in this style. 850702 × 841 ------------------- 850702 3402808× 6805616×× ------------------- 715440382 ...
Adarshyodha's user avatar
0 votes
3 answers
144 views

By the given task, the numbers can be 000, 001, 002 and so on. How can I save this number format? int i = 000; i++; System.out.println(i); //the output is 1 but I want 001 So how can I have the ...
rozerro's user avatar
  • 7,378
0 votes
2 answers
61 views

I'm working on a code which prints an array of locations, either in ascending or descending order. However, the formatting is all wrong for two out of 12 locations. Code: import java.util.*; import ...
Armaan Shah's user avatar
0 votes
0 answers
35 views

I built a table in Java. Now I want to close the right side of the table using vertical bars. I want it to loke like this: +------------------------------+--------+--------+--------+--------+----------...
wolfus's user avatar
  • 41
127 votes
3 answers
29k views

We currently use apache collections, string utils, etc. I need to decide if we should switch from the apache foundations implementation. The important criteria is ease of developers use. Performance/...
Pat's user avatar
  • 5,951

15 30 50 per page
1
2 3 4 5 6