-7
votes
3answers
36 views

Extract time from a String and convert it to a Long [on hold]

What I'm trying to get is to translate a time String to an Long. Which make it easy for users to set time for certain goals, but I have no clue how I can break down the String and transform it to time ...
0
votes
1answer
24 views

Creating Java String with Escape Sequence

I am trying to create a String which has the below value, but I am getting a syntax error. can anyone please help on this. tr -d '\15\32' < shell.sh > com.sh I need the final output in a ...
-4
votes
0answers
55 views

Java Programming with Arrays [on hold]

Recently I got test to write Java program for: here the input is string(eg. MAN or BAND etc..), and output should be integer problem statement: A=0,B=1,C=A+B,D=C+B so on., program should return the ...
-7
votes
3answers
41 views

Android replace double quotes with one quote [duplicate]

The string output is "data", "data1", "data2", "data3" i want it to replace " with ' so the string output will be 'data', 'data1', 'data2', 'data3' Thanks :)
0
votes
0answers
31 views

Regular Expression for String with Array [on hold]

I have a String with array of values: Last, First, company... I can have any number of fields. I have a ER to strip the value from the String with 1 value. I put 2 together to work with a String with ...
0
votes
2answers
47 views

Cut a specific part of String in loop

I have a String like this: String content = "{"begin"bf3b178a70.jpg","end",....},{"id":,"f06190e8938.jpg","end",....}" and i want to cut out the image ID like this: bf3b178a70.jpg f06190e893.png ...
0
votes
6answers
49 views

Java : Extract numbers from a string

I was trying to extract my data from a string by using regular expression. My data looks like: 12 170 0.11918 170 12 0.11918 12 182 0.06361 182 12 0.06361 12 198 0.05807 198 12 0.05807 12 ...
0
votes
2answers
24 views

Create a new Shape from the value of String.valueOf(Object obj)

I'm trying to figure out the most efficient way to create a new Shape instance from given String, which is e.g. a value returned by String.valueOf(Object obj) static method for the Shape parameter. ...
3
votes
3answers
71 views

Which methods of the String class to use to get string after a white space?

I started a java course a few weeks ago and today we were given a question sheet we will be doing in class tomorrow. I wanted to have a go at it myself tonight but alas I'm stuck on question 1. We ...
0
votes
2answers
56 views

Can a regex match “any whitespace that is not between quotes”?

Regex string matching everything not wrapped covered the task of retrieving characters outside distinct delimiters, but is it possible to do the same for equal delimiters? In other words, I know a ...
-1
votes
2answers
41 views

What is wrong with my application which uses the Vector class and while loop?

Could you guys give me some help over here with my not working application? First it has to prompt the user for a string for input and the prompt continues(while-loop) until when the user types "QUIT" ...
0
votes
0answers
17 views

Read Pasted Password with JLine?

I'm trying to mask a password entry using JLine. This can be accomplished really easily like this: password = console.readLine('*'); The problem is that will only mask the input character by ...
1
vote
0answers
12 views

Provide localization template without hard coding default values

In my Android app, I have an XML file /res/values/strings.xml with default strings, like this snippet: <string name="string_1">String 1</string> <string name="string_2">String ...
0
votes
4answers
58 views

Regex to split string on double quotes keep only content between quotes

sorry for the inaccurate Title, but i didn't know how to put it. If my string would look like this: 1+"."+2+"abc"+3+","+12+"." and I would like to get an array containing only the content between ...
0
votes
2answers
36 views

Escape symbol while spliting string using regex in java

I have a string that recieved while parsing XML-document: "ListOfItems/Item[Name='Model/Id']/Price" And I need to split it by delimeter - "/" String[] nodes = path.split("/") , but with one ...
-1
votes
0answers
34 views

Combinations of string array elements in Java [duplicate]

Suppose I have an array with elements arr = {'A' ,'B', 'C'}. I wants to create possible combinations of the array as: A, B , C, AB, BC, AC, ABC in Java
0
votes
0answers
15 views

Null condition giving wrong outputs for hash look up [on hold]

So I have an assignment which needs me to check if words are within a hash table. No errors actually occur, but I am getting the wrong output. When certain words are within the hash table, it never ...
-1
votes
3answers
43 views

.length cannot be resolved or is not a field

I have tried really hard to solve this with previous similar answers, but am still nto able to see my problem, hope you can help. My code looks like this: String MyContent =" "; String nextline = " ...
2
votes
1answer
46 views

Regular Expression for partial match length - String similarity

Say I have the string "Torcellite" and another string "Tor" - the similarity length of these two strings is 3 since both of them begin with "Tor". Now another string "christmas" and "mas" would have a ...
0
votes
2answers
33 views

HashMap Inside Hashmap printing involving strings?

I need to be able to get a value from a HashMap that is inside another HashMap. I'm not really that familiar with HashMaps so I can't really figure this out myself. Code: import java.util.HashMap; ...
1
vote
5answers
45 views

Dissapearing Arraylist Values

I am writing a Java program that will take a sentence (or phrase) and translate it into a group of objects that the computer can easily read. I wanted to make a simple word separating program, and ...
-1
votes
1answer
58 views

Conditionals with int and string [duplicate]

I'm making a payroll program and one of the options is to check data on current users. I want to allow the user to enter either the employee's ID or name to retrieve this information. Scanner ...
-1
votes
3answers
72 views

Efficient string concatenation algorithm

This is a follow up question to : Concatenation by += slower than that by using StringBuilder() where I found out that string1+=string2 is much slower than string1.append(string2) where string1 is now ...
1
vote
3answers
44 views

Does StringBuilder.append() method fills up the string pool?

I know that using most of String's methods will return a new string object which is added to the string pool and that the string literals passed as arguments to these methods also are added to the ...
-2
votes
2answers
55 views

parse string array to get integer value in java [on hold]

I have an string like"2=33=file". I can get the first number from the string by char[] cArray = new char[4]; int nValue = Integer.parseInt(String.valueOf(cArray[0])); How can i get the value "33" ...
-3
votes
2answers
38 views

java - string functions are not changing the input string [duplicate]

Following is my code: class program{ public static void main(String[]args){ String str = new String("I like Java "); str.concat("the most"); str.toUpperCase(); ...
0
votes
1answer
42 views

'messy' string to int conversion java

In my code I need to convert a String to an Integer - the String comes from the extraction of metadata, which is then compared to a array of numbers and their corresponding genres. Unfortunately the ...
3
votes
2answers
37 views

Splitting based on double dots excluding single dot in Java

I have a String str1 below written in Java that I would like to split. String str1 = "S1..R1..M1..D2..N3..S1.R1.M1.D2.N3.S1R1M1D2N3"; I would like to split the string into following elements in an ...
5
votes
5answers
45 views

Why we Pass String array as argument to main() method, why not any collection type or wrapper type or primitive type?

why is it mandatory to pass string arg[] as an argument in main method? why we cannot pass any other data type available in java? whats the importance of passing String arg[] in main method in java?
0
votes
2answers
37 views

Getting a substring from a string after a particular word

I have below String. ABC Results for draw no 2888 I would like to extract 2888 from here. That means, i need to extract characters after no in above string. I'm always extract the number after the ...
0
votes
3answers
68 views

How to count uppercase and lowercase letters in a string?

yo, so im trying to make a program that can take string input from the user for instance: "ONCE UPON a time" and then report back how many upper and lowercase letters the string contains: output ...
0
votes
2answers
35 views

java regex replace any double letter in word with single

I've been searching for hours but can't find an answer, I apologize if this has been answered before. I'm trying to check each word in a message for any double letters and remove the extra letter, ...
3
votes
4answers
35 views

Why does this not work string a = “\u” + “30A0”;?

Why does this work... System.out.println("\u30A3"); output -> ィ when this does not work? System.out.println("\u" + "30A0"); output -> invalid unicode Any ideas on how else ...
-4
votes
1answer
37 views

java .split function giving error [duplicate]

I am trying to split a txt file at every new line but when i am trying to print the split file it is giving me the error this is for my course work where i have to take input in a file and the ...
2
votes
2answers
84 views

Is there a O(N) solution to getting top k most occurring string in List<String>? [duplicate]

The problem is: Given a list of strings and an integer k, return the top k most frequently occurring words in descending order based on frequency. This must be done O(N) where N is the length of the ...
1
vote
2answers
47 views

Is there a way to use a string to pick a variable?

Let's say we have the following code to switch between sprites in an animation. There are eight directions (north, north-east, east, etcetera). We switch between them and now we pick a sprite based on ...
0
votes
2answers
29 views

Regex to Split String is not working well for “[,,.\\s]” in Java

I hope to split a String into groups by"," or","(Chinese comma) or "." or any blank char(like white space or "\n"). I am new to regex. I write the below test case: String str2="word1 , ...
0
votes
1answer
29 views

Split numbers and letters in an Alphanumeric String

I need to split an Alphanumeric String and split the alphabets and numbers. For example, if I have a string like: "Room 502", I need to get the number 502 as a separate string to "Room". Could someone ...
0
votes
0answers
35 views

How can I convert a string to an object reference? [duplicate]

The issue I am having is I am trying to write an app that has the user put in their customer number, and that string then calls the appropriate instance of the object. public static void ...
2
votes
2answers
55 views

How to escape slashes that are to be part of the string?

Im having difficulty finding a way to escape these quotes, String key = StringUtils.substringBetween(html, "class=\"category_keyword\"", "&gt;"); Specifically this part: ...
1
vote
1answer
38 views

Displaying an Integer as an output of Xs

So, I'm pretty new to the Java language and am having problem with a homework assignment. I need to take a console input from the user and display the number as a line of Xs. (i.e. "Cars sold by Pam > ...
-8
votes
2answers
39 views

string copyValueOf in java [on hold]

public class stackcall { public static void main(String args[]) { string a = new string(); System.out.println(a.str1); } } class string { static char str[] = ...
2
votes
1answer
52 views

Method Local Strings Memory Allocation?

I understand how String pool and intern() method works in java. Here is a brief introduction. String.intern() in Java 6 In those good old days all interned strings were stored in the PermGen – ...
-4
votes
2answers
23 views

Extract matching words from files

I have several text files and a data set of several words. I have to match for every text file what are the words that are matching. How can it be achieved? I initially started with tokenizing each ...
0
votes
1answer
74 views

String naming convention in java

I am currently trying to make a naming convention. The idea behind this is parsing. Lets say I obtain an xml doc. Everything can be used once, but these 2 in the code below can be submitted several ...
1
vote
1answer
43 views

Converting from different arrays to standard form

I would prefer a small sample code that i could remake into a larger scale of this question(s), or a link to a specific question/tutorial regarding these question(s). What i have done is i've stored ...
0
votes
4answers
78 views

Need advice for my java if-statement

i wanna be able to use an if-statment like this: int price = 60; if (pizza.equals("string1","string2","string3")) { int price2 = 10; System.out.println("You want " + pizza + " and it will ...
0
votes
4answers
32 views

Android: format string and add bold style

I have a string in my resource: <string name="region"><b>Region:</b> %1$s</string> I am trying to set this text to a textview: ...
-2
votes
3answers
49 views

In Java, what's the best way to get numbers from a one-line String? [on hold]

For example: input: 14 5 1 What's the best way to get these three values into three int variables? Also, does it make any difference if we were dealing with double values?
0
votes
1answer
30 views

Converting an String array into char array to compare it with another text file [on hold]

Given two files random_letters.txt AABBBBB FLOWERS BACKGFD TOBEACH dictionary.txt flowers to beach back I need to check each combination of the random_letters with dictionary to see if there is ...