Skip to main content

All Questions

Tagged with
0 votes
0 answers
36 views

Java's split method work differently on different strings [duplicate]

I'm trying spliting strings by using String.split() method. And when I use String test = "a "; String[] split = test .split(" "); this array's length is 1. But when I use ...
IkarashiAkatuki's user avatar
0 votes
4 answers
128 views

How do you split at the end of the line in Java?

I have a .txt file that looks like this: Event=ThermostatNight,time=0 Event=LightOn,time=2000 Event=WaterOff,time=10000 Event=ThermostatDay,time=12000 Event=Bell,time=9000,rings=5 Event=WaterOn,time=...
4K4K1N's user avatar
  • 1
0 votes
2 answers
356 views

How can i get access to elements of string array inside of a stream?

I need to count and sort hashtags inside string using stream api. example: String posts = "Example #java #streams string etc." I've tried to split this string to String[] and then iterate ...
dan's user avatar
  • 41
0 votes
3 answers
497 views

How to convert text to pojo by SEPARATOR

I have a string text, the formatter like CODE@NAME, and the NAME maybe a null value, just like below text: 202304110940436402@SHX01,202304110940477328@,202304110940494662@SHXZ20 The pojo: public ...
wang junweiiii's user avatar
-2 votes
2 answers
60 views

How can I use regex expressions to split a string between numbers, specified strings, and individual characters if they don't form a specified word?

I am trying to find a way to split a String into certain sections using a regex. My desired result would be like this: input: "3.0catsdogs}qd7cats8.0dogs" //specified strings: "cats&...
DillyWIlly's user avatar
0 votes
0 answers
40 views

Array error when capturing more than 9 words from a string

I am currently in a Java course and have run into a simple issue. I have tried several things to resolve the issue but no luck. When I give the input: "5 Hello world and goodbye world" I ...
JUNKJACKZACK's user avatar
-4 votes
1 answer
54 views

Longest Name in the list and Average birth date of all

My aim is to calculate the birth date of each person in the list we input as shown below and also output the longest name between them. Desired output: sauli,1948 tarja,1943 martti,1936 mauno,1923 ...
Amin Mousavi's user avatar
0 votes
2 answers
54 views

Why is my split method is not functioning as intended when I am splitting numbers from operator

Output of the code public class Model { private Scanner sc = new Scanner(System.in); private String expression; private String exp[]; public Model() { expression = sc.nextLine(); ...
IamTufa's user avatar
  • 13
0 votes
2 answers
95 views

java .split() method gives arrays of different lengths

I am reading lines from a tsv file, and then trying to delimit them by words = array.split("\t") words is an array that i have already initiated by String[] words = {"0", "0&...
Stelios P.98's user avatar
0 votes
1 answer
41 views

Split the String when it contains operation symbols in Java? [duplicate]

I want to split the string when it contains the symbol "+" and "-", how can I do that? Example: str1 = "2x^3+3x-8"; //Result: ['2x^3', '3x', '8']
joshxb2's user avatar
  • 15
-1 votes
1 answer
57 views

How to split String using array to read two inputs in switch

I have a database, where I need to make the user type two criterias they wanna sort the database by. If they for example want to sort it by name and height. It should then first sort it by name, and ...
Andreas Larsen's user avatar
-1 votes
2 answers
582 views

use .split() for files. java

I have a file and want to split the file line by line. But I do not want to create a new file each time. just store every line in an Array. the .split() method is exactly what I want but it can't be ...
asgr's user avatar
  • 35
-1 votes
1 answer
92 views

Problem with seperating one String into two arrays (words seperated by Tab and Enter)

EDIT 02.10.2022 - Got it working, have a look at the End. I am trying to make a program that splits one string of text into to arrays the input in the String text looks as following: voc1 deut1 ...
TheArtificalAI's user avatar
1 vote
1 answer
97 views

How to organize (from highest to lowest) a hand of 5 deck-cards? or how to split an array of strings into sub arrays?

I am stuck on how to organize 5 cards from highest to lowest. the 5 cards will come into the method as an array called handDeck, the array would look something like this: {"Ace spades", &...
hobbyiscoding's user avatar
0 votes
2 answers
851 views

How to split text from file into an array

I want to read from a text file which contains information about books. The information about the book should be put in an array. I understand I need to split. The content in the text file looks like: ...
Bella's user avatar
  • 1

15 30 50 per page
1
2 3 4 5
37