Questions tagged [charat]

The charAt() method is used to provide a single character by its index within a string.

The charAt() method is used to provide a single character by its index within a string.

261 questions
3
votes
5 answers

For loop can 'see' forthcoming values in current iteration?

I am working my way through CodingBat's Java exercises and I came across the CountXX problem, which counts the amount of times xx appears in a string. Here is how I solved it (I wasn't expecting it to work): int countXX(String str) { int count =…
alanbuchanan
  • 3,225
  • 4
  • 30
  • 58
3
votes
2 answers

Beginner java using charAt and using user input to display characters

import javax.swing.JOptionPane; public class MyJavaProgramTask4Exercise3 { public static void main(String[] args) { String Namestudent, studentID; Namestudent = JOptionPane.showInputDialog("Type in a student name: "); …
paulc01
  • 41
  • 5
3
votes
7 answers

string index out of bounds error in java (charAt)

Quick question. I have this code in a program: input = JOptionPane.showInputDialog("Enter any word below") int i = 0; for (int j = 0; j <= input.length(); j++) { System.out.print(input.charAt(i)); System.out.print(" "); //don't ask…
Kyle
  • 180
  • 1
  • 1
  • 10
2
votes
1 answer

i want to print the value of "i" from 0 to 1000

/*how ican make String.fromCharCode(i) i take value from 0 to 1000 so print out letter every time */ JavaScript For Loop