0
votes
2answers
28 views

Check in an array in java if value is lower than previous value and split it

I have an array with times String[] times = {"08:00", "09:15", "09:45", "08:15", "08:45", "09:30"}; And I want to loop through every value of the array and check if it is higher than the previous ...
3
votes
2answers
75 views

Java method params: var args vs array

Throughout the Google Guava library, I have noticed the tendency to use the "one (or two) plus var args" technique. Examples: void add(T value, T... moreValueArr) void add(T value, T value2, T... ...
0
votes
0answers
25 views

how to make a listview that contain arrays?

I wish to make a listview of array(s), but i can't seem to get it to work, you can see my code a bit down. I'm trying to have my listview contain Bitmap[], String[], and double[] but according to my ...
2
votes
3answers
70 views

Is this how to re-use code in OOP?

I have a class with a method that generates random data to fill arrays with. The class had the data member private final Random rnd that is initialized in the constructor with new Random();. This is ...
-3
votes
0answers
9 views

How to prevent an dynamic entity from moving off the desired route of J Buttons?

In my Program I created a "map" which my game takes place. On the map I have buttons I want the player I created to be able to move on. Those buttons have been put into their own array. So how do I ...
1
vote
4answers
49 views

How to change position of the elements in an array

I'm writing a program, that take 10 Integers from a keyboard and list them in an array indexed from 0-9, and reports the position of the lowest number in the array. If the lowest number has any other ...
0
votes
0answers
23 views

(JAVA) How to keep counter on which side the Object was dragged to (left or right)

I'm trying to write a code where it displays an Item in middle that can be dragged to left button or right button that says "no" and "yes' so far I was able to make it drag to each side, update the ...
0
votes
2answers
22 views

How to transfer arrayList elements into a 2D array?

I have an ArrayLists called List<Pair> patternList = new ArrayList<>() that contains a number of patterns of length 2. for example, for A={1,2,3,4} I create some patterns like ...
-3
votes
3answers
53 views

Faster way to specify character array filling?

import java.util.Arrays; public class ArraySpecification { public static void main(String args[]) { char[] correctLetters = {'a','b','c','d','e'}; Arrays.fill(correctLetters, 0, ...
1
vote
1answer
42 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
49 views

All possible combinations and subsets of an array in java

Given an array of variable dimensions.... E.g. array={1,2,4,5} I need a way to generale all possible combinations and subset of the array. Given an array of n elements I need to have all subsets ...
4
votes
2answers
42 views

Java: deserialise a json array with nulls

I have JSON that looks like this: { "values": [ [ 123456, 789.0 ], [ 123457, null ] ] } The "schema" is: each value is an array of exactly two things, ...
-7
votes
2answers
55 views

How to take average of number of values greater than some value in array? [on hold]

Lets say there are 100 number 1-100, How can I display if 30 % of the numbers are greater than 100? Here is the code to check if the value is greater than limit. The limit is declared as 70. public ...
0
votes
2answers
38 views

How to find if a field is an enum array using reflection?

I want to find out in Java, using reflection, if a particular field is an array of enums. Does anyone know how to do this?
0
votes
2answers
19 views

How to switch to another activity after the last element in an array is displayed?

Im new in programming and im having difficulties with my program..I want to switch from main activity to result activity after the last element in array is displayed but seems like my if else ...
-6
votes
0answers
34 views

How to check if 50 % of all values are higher than some given value in java? [on hold]

I have some values in database(1-100). How will I check if the 50 % of those values are higher than 70 through java code? I have written a code which will fetch all the number from 1 to 100 from a ...
11
votes
1answer
58 views

Char array compile time error upon assign a value from array

So I have this code char [] a = {'a','b','c'}; char c = 'a' + 'b'; //works char c2 = 98 + 97; //works char c3 = a[0] + a[1]; //compile time error So all of them are the same functionality but upon ...
0
votes
2answers
48 views

How to print out an array?

Ok so this is a code that should be able to print out an array and say how many times the numbers 0-9 were inputed through scanner, if a negative number is given, the point is to stop the program and ...
-1
votes
5answers
44 views

What data type is STRUCT in java?

I saw a already written old java code today which had these lines: STRUCT accDetail = new STRUCT(t_account_details, conn, itemAttributes); STRUCT[] accDetails = {accDetail}; What kind of ...
1
vote
3answers
55 views

Why can you change field variables with an enhanced for loop but you cannot initialiaze objects?

I recently learned that you cannot initialize objects using an enhanced for loop in Java because of the way an enhanced for loop works by creating a 'dummy' object from the object and then performing ...
-4
votes
2answers
58 views

java, how to find 4 of the same number?

I need a code that will find four of the same num and tell how many there are in a given array. int tnum =0; int q = 0; int[] spot = {689, 690, 690, 689, 689, 690, 689, 688, 688}; int[] ...
0
votes
2answers
35 views

Getting an array of integers from R.array in Android

I want to get the separate arrays from an xml file. The thing is, i need to get those arrays depending on variable i value. For example: First get R.array.p100, then R.array.p101 ... (int ...
-5
votes
1answer
33 views

How do I test if an object contains user-inputted String? [on hold]

A Vip has the following fields: name, contactNo, age, memberID, and exercise public static void main(String[] args) { People[] peopleArray = new People[9999999]; peopleArray[0] = new ...
1
vote
6answers
49 views

How to count occurance of element in array? [duplicate]

I have written a class such that is given below as shown that public class Countletter { public static void main(String args[]) throws IOException { String str = "muhammed"; ...
0
votes
3answers
37 views

C union of integer to bytes read by Java and reconverted to Java int

I want to send an integer coded as a byte array over a serial line with C and receive it using java and put the array back to an java int. I'm using rs-232 to send four bytes in a byte array packed ...
1
vote
1answer
38 views

NullPointerException on array with length one initializing

This is my method to updateHighScoreRecords(): public GameRecord[] updateHighScoreRecords(GameRecord[] highScoreRecords, String name, int level, int score) { GameRecord[] gameRecord = null; ...
0
votes
0answers
49 views

Java How can I set up an “unlimited” ListView

I didn't knew how to set up my Title properly to make you guys understand what I'm actually looking for so I hope my english will be good enough to tell you guys what's my current problem is. I'm ...
1
vote
2answers
46 views

Separating a 2d Array into Regions

I want to separate a 2D Array into 4 regions. I already did it with a 5x5 array. Is it possible to do it with a 10x10? I've been scratching my head for the past 5 hours. Here's my 5x5: char array1 ...
0
votes
5answers
52 views

Comparing the reverse word of a string to the original string Java

This is the solution I came up with: public void reverse(String str1, String str2){ int j = str2.length() - 1; if(str1.length() != str2.length()) { return false; } else { for(int i = ...
0
votes
3answers
57 views

How to replace a Date that I add to an ArrayList

ArrayList member = new ArrayList(); member.add(new Member("V0001","Amy","0000-0000-0000","012-3456789","01-01-2014","01-01- 2015")); private String memberId=V0001; private String memberName=Amy; ...
0
votes
1answer
71 views

Initializing array: java.lang.NullPointerException

So, I am having this bizarre error while initializing an array. What happens, is that I create an array, and it will throw java.lang.NullPointerException. As you can see on the second line, I do it ...
0
votes
1answer
32 views

How to generate array of text labels for date interval chart programmatically

I'm trying to implement a chart to show some interval based data. For the orizontal axis labels I need an array that contains all text labels. The problem is that: I have to generate this array ...
1
vote
2answers
44 views

Handling out of bounds on a fixed array

My problem is that for example there's only three passing grades, the user entered then the size of passGrade array would only be three, same with failGrade: if the user entered two failing grades ...
0
votes
2answers
32 views

Getting group of the same numbers numbers

I'm working on a code which will count how many are the groups with the same number. For example: 11022 = 2 groups with the same number 1100021 = 2 groups with the same number 12123333 = 1 group ...
0
votes
2answers
49 views

Converting a String representing a mathemetical expression into an array

I want to convert a String such as 1+40.2+(2) into a String array [1, +, 40.2, +, (, 2, )] in order to use it as a parameter for a Shunting Yard algorithm in my Calculator class. The input will be ...
-8
votes
2answers
65 views

Difference of int to int[]

What is the difference of int to int[]. Is it allowed to convert int to int[]. for example: int[] a = {}; int b; how can I pass the value of b to a?
-2
votes
1answer
45 views

How to create X number of elements in an array?

For an assignment in school I need to create a class that extends a "Wallet" class that has already been created. The contructor needs to accept an argument of how many credit cards this instance of ...
4
votes
1answer
65 views

Finding all possible sums of a set

I am currently looking for ideas on how to find all possible sums of a set of numbers with these rules. I have these numbers to work with and I want to find all possible sums so that you can only use ...
2
votes
3answers
57 views

Generating all possible combinations with a dynamic size d?

I want to make d here dynamic, i.e., I want to be able to generate all possible combinations of array values without knowing the value of d in advance. Right now, I'm using if-clause and I can only ...
0
votes
0answers
88 views

Strange ArrayIndexOutOfBoundsException?

I've ran in to a wierd error that I think shouldn't be happening, I first tested the code by hard coding everything in the driver, then I made a menu, and that's where it's happening. This is the ...
2
votes
3answers
62 views

The object-oriented approach to a many-to-many relationship

I'm battling at the moment in trying to understand how to approach this issue in an object-oriented way. With a many-to-many relationship such as Students-Subjects, where each student gets a mark for ...
0
votes
5answers
70 views

Pick a random element from a string array?

I've got this code, which (I hope) reads from a text file with 66 words and puts the words into an array. BufferedReader buff = null; String wordlist=new String[66]; int i=0; try { buff = new ...
0
votes
1answer
80 views

How to convert List<T> to Array t[] (for primitive types) using generic-method?

I am doing some tests with generic-methods and I'd like to transform these two methods below (convertFloatListToArray and convertShortListToArray) in just one (convertListToArray): public class ...
-4
votes
0answers
27 views

how to create arraylist associated with buttons click?

This is my code of two activity, how do I create ten other arraylist in the Activity B, one for each button clicked on the Activity A? ACTIVITY A ArrayList products; protected void onCreate(Bundle ...
-3
votes
0answers
46 views

Want help to create a student class using array [on hold]

I want to create a student class using array in BlueJ. I'm a newbie so please provide the complete code. My Requirements are as follows... Create Student class with attributes - marks, name, ...
0
votes
2answers
52 views

How to create a mixed Array inside an Array?

I'm new to android and I need some help to create an mixed array inside an array. This is what I need: myArray = {["String", int, int, int], ["String", int, int, int], ["String", int, int, int]}; ...
0
votes
1answer
53 views

Data structure for array of string arrays in java

I checked other questions and googled as well but didn't find a proper answer according to my demand. This is web app and I am using a rest service. I have a class Request and it has an attribute ...
0
votes
2answers
46 views

How to create a new array containing data from an other array in Java?

How do I create a new array from this array String[] data = {"day: monday, color: green", "day: sunday, color: blue", "day: thursday, color: red"}; that looks like this: String[] data = {"green", ...
-5
votes
0answers
19 views

JOptionPane for inputting String and then converting to integer [on hold]

How to a program that uses: JOption Pane for inputting String of 10-50 Convert the input String to an integer create an array of length specififed integers Use a for loop to populate the array with ...
2
votes
0answers
33 views

Passing multidimensional int array from Java to C (and back) using SWIG

I need to invoke from Java a C function that takes, as input, a bidimensional int array. The same array is used by the C function to provide its output. I modeled the bidimensional array as an array ...