Skip to content
Advertisement

Tag: arrays

Count occurrences in 2D Array

I’m trying to count the occurrences per line from a text file containing a large amount of codes (numbers). Example of text file content: I want to compare a similar set of numbers that I get from a text field, for example: 9107,4405,2387,4499 The only result I’m looking for, is if it contains more than 2 numbers (per line) from

How to generate random names on particular days in Java?

Here is my program which generates random name: I need it to generate the names based on last weekend check, if the generated name matches with last weekend’s generated name then the program to run again to generate different name. Ex: If “one” is generated on Saturday and “two” is generated on Sunday, then next week these two should be

start a char array from a certain index

I have a char array called data. I should write a method that makes it possible to return the array but with a starting point that is an integer variable called beginIndex. Example: array contains ‘A’, ‘B’, ‘C’, ‘D’ and beginIndex = 2. Then it should return ‘B’, ‘C’, ‘D’ (yes the index himself in this case the 2nd letter

Merge an List of Object and an Object to a new array in Java [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 10 months ago. Improve this question I have List<BigInteger> sample1 = Lists.newArrayList(BIGINTEGER1, BIGINTEGER2,BIGINTEGER3); I have to create new List sample2 with one more value BIGINTEGER4 along with sample1 list: How can

Random search on an array of size N

I need help fixing my code below. I want to do a random search on an array of size N. Random search randomly picks up an integer from arr to compare. And the process repeats until the integer it is looking for is found (again it is remarked that the membership is guaranteed, otherwise random search obviously can enter an

Counting words using parallel Java arrays

I am trying to write code to count the frequency of each word in an array. I am wondering if I need to use two nested loops to keep track of both the array with integers and the array with the words. I have been fiddling with the code for hours and cannot make any progress. If you have any

Advertisement