charAt « string « Java Data Type Q&A

1. "The left-hand side of an assignment must be a variable" problem with charAt

private String kNow(String state, String guess) {
        for (int i = 0; i < word.length(); i++) {

2. atoi in java using charAt

I know that one solution to do this is the following:

 String tmp = "12345";
      int result = 0;
      for (int ...

3. charAt

4. why won't charAt work?

I've written this code to create an array containing all the letters in a string. However, originally in my method, I used charAt, but I kept getting an error message. So, I tried substring and it worked fine. Can anyone tell me why charAt wouldn't work in this case? Thanks. public class CharArray { public String[] createCharArray(String s) { String ca[] ...

5. Pls help ! on charAt()

I'm not sure what startWord is supposed to be doing, but it looks like you're pretty close. What is it printing now? All the letters except a letter after a blank? If you're after every other letter you might toggle a boolean every time through the loop: if flag is true print a character flag = !flag Or a better hint: ...

6. charAt() problem.. plz help..

7. charAt(0)

8. charAt problem....

Keep getting an incomparable type error, i guess this is caused by my array? public void solveTaskOne() { for(int i = 0;i < 9;i++) { for(int j = 0;j < 9;i++) { if(blocks[i][j].length() == 1) { for(int l = 0;l < 9;l++) { for(int k = 0;k < 9;k++) { String value = blocks[l][k]; for(int m = 0;m < blocks[l][k].length();m++) { ...

9. using String.charAt() for semicolons

10. Help with charAt()

Hi everyone, I have looked and really need help with my specific problem. My code is as follows: int counter; for (counter = 0; counter < phrase.length(); counter++); { int p = counter; int shiftNum = Integer.parseInt(shift.trim()); System.out.print("\n" + phrase.charAt(p)+ shiftNum); } My variables are all accounted for and there are no errors in the code, but i keep getting this ...

11. charAt problem... Please help

import acm.program.*; public class Capitalize extends ConsoleProgram{ public void run(){ String str= readLine("Insert a string to capitalize: "); println(capitalize(str)); } private String capitalize(String word){ String result = ""; for (int i = 0; i < word.length(); i++){ char ch = word.charAt(i); if(i==0){ ch = Character.toUpperCase(ch); }else{ ch = Character.toLowerCase(ch); } result+=ch; } return result; } }

12. Why won't charAt() work?

13. Str.charAt() ?!

Yet again your lack of understanding shows. When you concatenate anything to a String what happens under the hood is that the code is changed to use a StringBuilder and amends the content regardless of its type. So converting the char to a String beforehand is actually causing the code to do extra work.

14. charAt problem

The CharAt method returns the char at the index you mention. For exmaple: st = "abcd"; st.CharAt(2) equals to "c" . As josAH said, I think you mean IndexOf, anyway you still can do it with CharAt: run a loop on the whole string checking each char if it equals to " " . if found return the index of the ...

15. Help with charAt and repeating methods


} } The program is to ask a user to key in the third character of the password which in this case is "marketing", so the third character should be r. if the user inputs the correct character "CORRECT CHARACTER ENTERED" else "INCORRECT CHARACTER ENTERED" should be displayed. The problem is that "INCORRECT CHARACTER ENTERED" is displayed even when the user ...

17. how to use the charAt method

> How would I use the charAt method (along with a counter) to locate and count the number of a specific character (for example, a period)? 1. Declare a variable to store the number of characters counted and initialize it to zero. 2. Declare a variable to store the length of the string, and initialize it to the length of the ...

18. A charAt() for Strings

19. problems with charAt()

20. Using the charAt() Method

I am creating an Applet which contains 3 text boxes. The user inputs two integers into the first two text boxes and enters the characters "A" or "S" into the third. Upon pressing the return key, if the user has entered the character "A" I want my program to add the two integers together, if "S" has been entered I want ...

21. charAt problems

22. charAt() funtion not working

= String(b.charAt(i)); } Yes well. You didn't use code tags and that code is just a mish-mash of bugs waiting to happen. This code doesn't make any sense. What is it that you really want to do? Because what you are trying to do is take a String and then arbitrarily take some characters from it and populate an array of ...

23. Isolating Digits using charAt or some other method.

Now i want to apply my algorhithm to every second digits starting from the right so "5,4,5,3" and leave the other ones alone. I was thinking of isolating every second digit using charAt commands or something. How will i go about doing this - that is isolating every second digit so i can apply my algorhithm. Edited by: Simplistic2099 on Feb ...

24. charAt == '\' problem

Its again the developers choice to use ' ' or to use 92. If I were aditya I would use 92 instead of ' '. Lets close this thread here as we have given a solution to aditya, now its upto him to use these options. Lets concentrate helping others on other threads. Thanks your opinion redfalconf. -- Choicest Regards Amit ...

25. why doesn't my charAt(i + 1) work?

26. charAt() Query