1
vote
6answers
45 views

Pointer with java and string variable

I gave a value (as variable) to a String variable. The problem is that when I change this value, it doesn't change the other variable : Code : String test = "hello"; String myname = test; test ...
1
vote
1answer
43 views

Can I cast an object to a string from an object array of strings. Getting classCastException

I'm probably being very silly, but it's driving me nuts. I have searched around but am relatively new to programming and am in over my head. Please help if you can! the bar parameter is taking an ...
1
vote
4answers
65 views

Java String split() loses string

I have a String called raw. I am trying to split it into an array like so: lines = raw.split("\\r?\\n|\\r"); This works well for the first few occurrences but then it breaks and totally loses the ...
0
votes
1answer
16 views

Warning message says that a value “can only be null”. It should be filled from Reader.Read(Char[])

It gives a message saying: "Null pointer access: The variable CharacterList can only be null at this location", when I think it should be filled from the FileReader.Read() method. public String[] ...
0
votes
2answers
61 views

Java: Getting a variable name from a string

I have some variables defined like this. public final static String pDrive = "\\\\fs-innova1\\projects\\"; public final static String hDrive = "\\\\fs-innova1\\hr-department\\"; public final static ...
0
votes
4answers
30 views

Using an if statement to detect words that begin and end with the same letter

I am trying to create a program using scanner which takes input from the user and determines whether the input begins and ends with the same character. import java.util.Scanner; public class L7E6{ ...
-4
votes
2answers
74 views

Replace String no matter uppercase and lowercase [duplicate]

Well.. i got the values in a ArrayList... How could do for "mark" the words that was getting in a "Description" value? f.e: Criteria = car matches founded... 2 Old Description value = My ...
0
votes
3answers
66 views

Issue with list.removeAll()

I'm using arraylists to find differences between two strings i.e str2 and str3. when i use the below code it works perfectly and returns the expected output. but when I replace str2 = #19, 6th cross, ...
0
votes
1answer
49 views

String immutability, pop quiz

There are a lot of questions concerning String immutability, but yet I haven't found an answer for why the following happens: 1) "TEST".equals("TEST") // TRUE obviously 2) "TEST" == "TEST" ...
-1
votes
6answers
58 views

Difference between using StringTokenizer and String.split( )?

I've been using String[] split(String) of String class to split any string for some given delimiter, and it worked fine. However, now it is expected to re-factor the same logic with StringTokenizer. ...
0
votes
3answers
47 views

Two strings are equal but wont work on if statement [duplicate]

System.out.println(characters.get(selected).getName()); // The name printed is "Mario" But the if statement will not // work as though the two strings are diffrent but they are the same. ...
0
votes
1answer
31 views

StringIndexOutOfRangeException

Im doing a simple program to check if user inputted words are a part of an alien language. Im getting an index out of range error message…any help? "String index out of range =" however many letters ...
0
votes
2answers
70 views

Basic String Help for Java (newbie here)

I have a program that supposedly prompts user to input a word, phrase, or sentence. I should then "encrypt" what you entered 13 times, printing every single time. The last thing printed should ...
0
votes
3answers
45 views

If statement String trouble [duplicate]

I'm trying to create a program which takes user input of two words and determines whether or not these words are the same. import java.util.Scanner; public class L7E3 { public static void ...
0
votes
2answers
47 views

Replacing a string in place [on hold]

I am having an issue with a problem from my Intro Java class and this problem is a bit more than I can wrap my head around. The problem is asking for a user to enter in a string and output the same ...

15 30 50 per page