loop « character « Java Data Type Q&A

1. java repeat character    stackoverflow.com

I am a java beginner, please keep that in mind. I have to make a program that reads a number, and then displays that amount of exclamation mark "!". This is what ...

2. How do I apply the for-each loop to every character in a String in Java?    stackoverflow.com

So I want to iterate for each character in a string. So I thought:

for (char c : "xyz")
but I get a compiler error:
StackCharTester.java:20: foreach not applicable to expression type
How can I do ...

3. duplicate characters in a loop    stackoverflow.com

I need to write a small program that takes in a string like Hello World and prints out HHHEEELLLOOO WWWOOORRRLLLDDD, but instead of just hello world it would take in any ...

4. Java - Indexes of all occurrences of character in a string    stackoverflow.com

The following code will print 2

String word = "bannanas";

String guess = "n";

int index;


    index = word.indexOf(guess)

I would like to know how to get all the indexes of "n" ...

5. for loop (remember where last to look) & Character.isDigit()    stackoverflow.com

I have to do a project about the periodic table of elements. My dilemma is as follow. The user send you a molecular equation. It can be of any length. In ...

6. Char in For Loop    java-forums.org

So basically I wrote code to encode any String using ROT-13. So, for example, if the String is "the", the ROT-13 encoded String will be "gur". Basically, the "t" shifts 13 letters, the "h" shifts 13 letters, and the "e" shifts 13 letters. Here is the code I have for it: Java Code: public void rot13() { for (int i=0; i

7. Drawing shapes with for loops using characters    java-forums.org

Hey guys, I'm trying to draw a shape that looks like this $$$* $$*$ $*$$ *$$$ However with this code it comes out as $$$* $$$* $$$* $$$* The beginning part of my code asks the user which shape they would like to be drawn, and the size of the shape. This is the code pertaining to the "diagonal" else if ...

9. char loop problem    forums.oracle.com

10. Create a string from looping characters    forums.oracle.com

11. Re: problem with char's and loops??    forums.oracle.com

12. Re: problem with char's and loops??    forums.oracle.com

13. Re: problem with char's and loops??    forums.oracle.com

14. Re: problem with char's and loops??    forums.oracle.com

15. Re: problem with char's and loops??    forums.oracle.com