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.

292 questions
-2
votes
3 answers
-2
votes
3 answers

how can I make charAt method work with arrays in java?

can someone help me with this problem ? i have to make method charAt to work but i dont know how.. class AsciiCharSequence implements java.lang.CharSequence/* extends/implements */ { // implementation byte[] array; public…
-2
votes
2 answers

How do you scan a text file and convert it to a 2D char array?

I have been given text files and I am trying to convert them into a 2D char array for further use. What is happening is it appears to be taking the first indices and copying that over and over until it has reached the int size and it believes there…
cb-9099
  • 13
  • 5
-2
votes
1 answer

java charAt() array issue

I have some sort of problem even tho, idk what it's actually that's my code package $Random_Projects; import java.util.Scanner; public class PhoneBook { public static void main (String[] args){ Scanner myScan = new Scanner(System.in); …
IRomio
  • 3
  • 1
-2
votes
3 answers

Strange behaviour at String addition on Java

I have noticed something strange when adding two chars in a string when casting them to an integer. For the following code I have s1 = "+1" and s2 = "+2" as input: String s1 = scanner.next(); String s2 =…
Jo An
  • 3
  • 2
-2
votes
2 answers

My loop can't find blank space in my String

I have been trying to make a program in which the user is asked to enter a sentence with only one blank, and once they do that, my loop is supposed to go across the string and find a blank space, then take the first name of the user and the last…
brn
  • 275
  • 1
  • 6
  • 17
-2
votes
2 answers

how to use long in string methods like charAt in java?

how to use long in string methods like charAt in java?? String s="google"; long i=0; System.out.println(s.charAt(i));
nitin
  • 1
  • 2
-2
votes
1 answer

charAt never works correctly from Scannner input

this is my code....and problem I need to have an input from user where the first letter is used , then from the second user input from 0 to 5 the characters are used, and finally generate a random number....I have tried everything for the second…
cpdl4485
  • 3
  • 2
-2
votes
3 answers

Java: .charAt not recognizing space character

I hate to bother on here, but a personal project of mine is persistently returning a stubborn error. Since I'm a computer science major, I've had a few fellow students look over it as well as my professor, to no avail. The issue is I'm trying to…
Eris Novae
  • 29
  • 1
  • 9
-2
votes
3 answers

string length, number of capitals, and number of numbers in a string

I want to check if a string has 8 or more characters, and if it has 1 capital letter and 1 number. This is my code: import java.util.Scanner; public class PasswordTest { public static void main(String[] args) { Scanner keyb = new…
-2
votes
1 answer

Printing userinput with charAt()?

I am a beginner in java and am having trouble with printing out userinput with charAt(). I need to create a program that takes userinput and adds "op" before vowels in that text. (example: Userinput -> "Beautiful" would be translated as…
CMCK
  • 1
  • 1
-2
votes
3 answers

how to compare word letters using if statements?

I'm trying to write a program that reads a word and prints if: it ends with the letter y. has the same first and last character, ignoring case. This is what I have so far, but I'm having trouble thinking of a line of code that will check…
Rod112
  • 1
  • 2
-2
votes
2 answers

Cannot find symbol charAt(int)?

Can someone please tell me what I'm doing wrong here. I'm trying to access a Map and put the keys which start with the letter "N" in an array. However I'm getting a Cannot find symbol error referring to charAt(int)? Intellij is suggesting me to…
Anthony J
  • 551
  • 1
  • 9
  • 19
-2
votes
1 answer

Using a method to find the letter in the inputted integer

"Write and test the method that returns a letter of the alphabet from a given word, it the position is given. (Hint: use the method that begins with static char getLetter (String txt, int n)." I've been staring at this question for 20 minutes, can't…
-2
votes
2 answers

Shouldn't input.charAt(0) return a String? Why input.charAt(0) >= int works?

I've been doing exercise. Write a Java program that takes the user to provide a single character from the alphabet. Print Vowel of Consonant, depending on the user input. If the user input is not a letter (between a and z or A and Z), or is a string…
rejnol
  • 3
  • 3