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
-1
votes
1 answer

The last position of char in string in R

I want to ask how can I take the position of last index of char=" | " in R My string will be similar like below: I have apple|Orange|banana|perry| in my bag. Thanks,
Afnan m
  • 11
  • 3
-1
votes
2 answers

Java Issue with String: Trying to reverse the midpoint of String.. String out of Range exception

I'm working on an assignment for one of my classes. I'm very new to java in general and for this problem I was asked to only use loops and the charAt(); command to reverse the midpoint of a string. However, I came to an issue when I try to reverse…
-1
votes
2 answers

Java: Left-hand side of an argument must be a variable charAt error

I am replacing all vowels in a String with a char using a for loop. public String replaceVowel(String text, char letter) { char ch; for(int i = 0; i
sid_mac
  • 151
  • 2
  • 10
-1
votes
1 answer

charAt not evaluating

I am trying to write a function that will evaluate equality of characters in a string and return true if 3 in a row match. The charAt() doesn't seem to be working as the if statement always goes to the else block. function myFunction(num1) { var…
B Minster
  • 331
  • 3
  • 16
-1
votes
2 answers

Having trouble with if statement containing string

I am having trouble trying to compare a string using charAt() for some reason it throws a fit when trying to compare it to "1". Can someone point me in the right direction? public static void nthDigitTally1(int n, int num, int tally[]){ String…
Kevin
  • 47
  • 5
-1
votes
1 answer

Additive operator used with char values produces different results

I am getting a strange return for the below block of code (sets of integer values): public String doubleChar(String str) { String answer = ""; for (int i = 0; i < str.length(); i++) { answer = answer + (str.charAt(i) + str.charAt(i)); } return…
-1
votes
1 answer

Indexing string for insertion into char[][][] array

I'm a little stuck on the arithmetic for this program. I have a string theString that has a length of x*y*z. x, y, and z are the dimensions of a char[][][] array (lets call it cArr). I want to insert the characters of theString into cArr based on a…
gator
  • 3,465
  • 8
  • 36
  • 76
-1
votes
5 answers

JAVA: Error reversing a string to check for palaindrome off-by-one i think

I am having a problem. I received an assignment to write pseudo code for a palindrome checking program. My problem is that while I received good marks on my pseudocode assignment, when I tried to write the code in java for my own edification, I was…
AllWillB1
  • 13
  • 3
-1
votes
2 answers

what's the error in this code?

what's the error her :( انا بحاجه الي حل هذا السؤال فكرتة في طباعه الحروف المتكررة في جملة يدخلها المستخدم public class Checker { Scanner Scan = new Scanner(System.in); int x; public Checker() { …
Mahmoud Alaa
  • 3
  • 1
  • 4
-1
votes
1 answer

Java: is there an int method like charAt()?

I don't want "charAt(1);" to return the character at position 1 in the string... I want it to report all instances of "matching = 1;" Take for example int matching = 1; int notMatching = 0; int HI = matching; int IH = notMatching; int…
Computer
  • 132
  • 11
-1
votes
2 answers

Checking if any letter is in any position using charAt() on button click

I am making a game of hangman, and am wishing for the code to check if the hidden word contains any letter from the alphabet, in any position. eg charAt(0), charAt(1) etc. Once it checks if the letter is in the word, i want it to set its…
Bison
  • 1
  • 1
-1
votes
2 answers

How can I store a word into a variable in a compass program

I need help to store a word in a variable and output my message from my compass program.I need to write a program that has the user enter a compass direction and then prints a message. I dont know why its not outputting the direction, do I need to…
Phineas
  • 83
  • 1
  • 2
  • 14
-1
votes
1 answer

Javascript CharAt method doesnt work for a string

var teksts= (document.getElementById("teksts").value); letter=document.getElementById("letter").value; var results = teksts.split(" "); document.getElementById("1").innerHTML = results var count = new Array for(var i=0; i
Reinis
  • 132
  • 2
  • 16
-1
votes
5 answers

Substring problems

I'm trying to break up a string 192.168.1.2:6060;rport;branch=z9hG4bKNskFdtGO4". I wanted to extract the port:ip before the first semicolon, and the branch number after the equal sign. The code I tried was temp =…
user1231232141214124
  • 1,339
  • 3
  • 16
  • 22
-2
votes
2 answers

Can someone please explain what is the use of 32 in this remove spaces from string method? java

public static String RemoveSpace(String s){ String str=""; for(int i=0;i