0
votes
6answers
50 views

initializing and passing strings in java

I am trying to make a simple coin toss simulation in Java, and after playing around with initializations and such, I can't get the String side initialization to be overridden by the toss simulation. ...
-3
votes
2answers
65 views

How to split string in java when there are multiple criterias to split [duplicate]

To split a paragraph into an array of individual words (say a string array), the most common answer would be something like: String para = "ameya needs to win this cup."; String[] abc = ...
-2
votes
4answers
60 views

Java - Compare SimpleDateFormat to String

I haven't been able to figure out how to compare a SimpleDateFormat to a String due to my unfamiliarities with Java. The problem seems to be in these lines: SimpleDateFormat today = new ...
-2
votes
0answers
48 views

how String made immutable in java? [closed]

i am pretty clear about why Strings are immutable in java but my question is how API developers made it immutable?? i guess this is not due to just final modifier because it just prevents from ...
0
votes
1answer
23 views

Pixels that text will give

Would it be possible to get the width of a string based on its font? So for example, if the font size is 40, and the string was "hi", could you do 2*40. An example of this would be startX = 260; ...
-4
votes
1answer
48 views

Java - Get specific word from string [closed]

I have a string that is like this: String programList = "List of programs: explorer.exe, conhost.exe, java.exe, something.exe.."; I want to create every word that has the ".exe" to its own string, ...
2
votes
4answers
50 views

How to name an object reference after a String [duplicate]

For example, we have String name = "Peter"; and we want the particular instance of a hypothetical Employee to be named after this string, as in Employee ____ = new Employee(...); So what do I ...
0
votes
3answers
58 views

How to ignore characters before and after my pattern?

I need some help creating a regex (in java) to find a pattern like: (30.6284, -27.3493) It's roughly a latitude longitude pair. Building from smaller pieces, I've come up with this: String def = ...
1
vote
4answers
47 views

Java Cast from Object to long to String

Here's the situation, I have an Object in a Map which I explicitly know to contain an instance of Long and I need to turn that value into a string but keep getting incompatible type errors. Here's ...
0
votes
1answer
25 views

Convert Points to textual representation

Let's say I have two Points new Point(80,40); new Point(40,80); And I want to convert them to end up as one string, a String representation. 01 10 Where 1 is a point, and 0 is empty space. You ...
0
votes
1answer
28 views

Converting a byte array (byte[]) to String changes one special character

In Java, I try to convert a byte array (byte[]) xml into a string using: String output = new String(myXMLbyteArray, "UTF-8"); This is successful except for one special character, the acute ...
0
votes
3answers
56 views

How to compare two StringBuffer Objects using .equals() method? [duplicate]

The following code did not work. Can anyone tell me what's wrong with the following code. Logically it should work... package assignments; import java.io.BufferedReader; import java.io.IOException; ...
0
votes
3answers
55 views

Pattern.compile.split vs StringBuilder iteration and substring

I have to split a very large string in the fastest way possible and from what research i did i narrow it down to 2 possibilities: 1.Pattern.compile("[delimiter]").split("[large_string]"); 2. Iterate ...
0
votes
2answers
33 views

RegEx to split string based on operators and retain operator in answer

I want to split string based on few operands. For e.g. String : a&&(b||c) ANS : String[] {a,&&,(,||,c,)} IS it possible with java RegEx? If yes then how? I tried with ...
-6
votes
1answer
38 views

Adding date-time at the end of a String in Java? [duplicate]

I want to add the date and time of the creation of a file at the end of its path-String? So I need to get the creation time of this file from the system and concat it to the end of the String. What is ...

1 2 3 4 5 491
15 30 50 per page