Tagged Questions
0
votes
1answer
39 views
Getting long array separated by line break - how to parse? Android
I have a function which gets an object, after that we decide the instance type.
...
for (String key: keys){
Object tmp = bundle.get(key);
if (tmp instanceof Boolean) {
...
...
I ...
0
votes
2answers
88 views
Why is my method giving me the null value?
I dont understand why I am receiving such a value. This method depends on an array directly and another two indirectly. They are all filled with a similar amount of steps however the method by which ...
0
votes
1answer
18 views
Image-mouse intersection / hover effect issue when using arrays
I'm working on a small exercise that involves making an interface of six die faces. The goal is to change the color of each die face when I hover over it. The issue I'm having is that I can only ...
3
votes
6answers
43 views
2D Java Arrays. Turning Negative numbers to zeros
This method should input a 2d array of ints (int[][]) and returns the 2d int array with all of the negative numbers replaced with zeroes.
For instance, if you send it {{4,5,-6},{7,-8,9}}, your ...
0
votes
2answers
24 views
java storing data from file into separate array
I have a question on how to store data from a file into separate arrays. In my case, I need to read a file and store the data into separate arrays, one for the name of the hurricane, the wind speed, ...
0
votes
3answers
33 views
Adding multiple boolean arrays together
I have this method that adds two 2d boolean arrays together. So for a given cell, if any array is true for that cell, the cell in the resulting array is set to true.
private boolean[][] ...
3
votes
3answers
42 views
How to dermine if a value of type int is a match in an array?
Here is the code I have so far
int []d = {2,18,4,4,6,8,10};
int matchNumber = 4 ;
i=0 ;
for(i= 0; (match==d[i])&&(i < MAX_SIZE-1); i++);
{
...
0
votes
1answer
42 views
Sorted an array of strings alphabetically. How do I sort the same array by a number in the middle of each line
This is my list of Players and their Scores that I need to input from a text file, sort alphabetically, and then output to a new file. I then have to take the same list and sort it based on the ...
0
votes
2answers
27 views
How to find the highest value in an array and its position
So I have an array and I know how to find the highest value but I can't figure out how to obtain the position of that value in the array. The method so far is as follows:
public static void ...
1
vote
1answer
22 views
Java, ErroMax and Min of Array object data?
I need some help with max and min. This code section is from the main method of my Annual Fuel Use class. The program projects my annual fuel usage based on at least three fill ups of my car.
I am ...
0
votes
0answers
46 views
Alternative method to initialize a variable [on hold]
Ok, so I have a program where you can buy different type of cards, and I want to store them in an array in a different class via "cardsystem.inputCards". The following snippet of code receive an int, ...
0
votes
3answers
30 views
Java using scanner to access array elements
I've created an array 8 elements long using the scanner class. I'm trying to accept user inputs via scanner and print out the value at that index location. eg if the user enters '2', it prints out the ...
1
vote
1answer
29 views
How to get sub image from a sprite sheet into an array Java
Okay so I have a sprite sheet that will be 5x5 and each sprite is 20x20 pixels. I need to get each item of that sprite sheet into an array. I made a for loop but got an error. So I tried defining one ...
-2
votes
2answers
51 views
How to count the frequency of each number (java) [on hold]
I have created this file to out put 100 random numbers. I am trying to figure out how to create an array to count how many each number appears, from there I will need to find the frequency as a ...
0
votes
3answers
59 views
JAVA:How to output Array in 2 directions
My Title may sound a bit silly, so here is the explanation:
I have an Array
int[] a = new int[] { 1, 2, 3, 4, 5, 6 };
And the output in the End should be like
123321
I already managed to ...
0
votes
2answers
43 views
Java String Array Vowel Method
write a method in java that takes an array of Strings as an argument. Each element of the argument array will contain a single word.The method must return an array of strings that contains only the ...
0
votes
1answer
40 views
Parsing JSON Array using GSON
I have a basic JSON with all data contained in an array. One would think that it would be simple to retreive a value out of the array, but after multiple hours of trying every different method of ...
0
votes
1answer
31 views
Splitting an array to be input into a Map
I am trying to split an array of names such as "Joe Bloggs" Joe and Bloggs are separate and then can be used in a map where the first name is the key. Here is what I have so far.
public static void ...
0
votes
2answers
56 views
Reason for it telling me NullPointerexception
Why is this giving me the error of Nullpointerexception? It is happening on the 3rd line of my code, so my first for loop. Just so you know, this is a method with access to other parts of a larger ...
1
vote
1answer
29 views
Scanning from a file and getting a null pointer exception in java
I am very new at this so I apologize if this may seem very basic. Anyway I am trying to read input from a file and put that data into an array so that I can graph it later. the problem I am having is ...
1
vote
5answers
54 views
Calling an array that's inside another array
Bear with me, this is a bit long. This class here is creating a student object:
public class Student {
String firstName;
String lastName;
int assignmentScores[];
int labScores[];
...
0
votes
1answer
27 views
Using JNI to pass a C pointer to a double array to Java
I am trying to use an external C library in a Java program via JNI. I need to use two functions, the first is a calculation in C and stores some results in a double array, the second function then ...
0
votes
1answer
47 views
remove a null character in last of String array before storing database
I am Storing Values from String Matrix (which is filled from a text file) to DataBase Table.
everything is working fine,but the values that are stored in Database have blank space after each word.
I ...
0
votes
3answers
65 views
Java toString Issue
I am having an issue with the toString method in Java. Here's the run down... I have a database that I am querying. The query returns all of the members in the database, and I'd like to return these ...
-4
votes
2answers
51 views
Replace the lowest value of an array [on hold]
I have an array of three ints and an array of three strings.
I want to be able to find the lowest int in the array and replace it if the "next value" is higher. If the lowest int is replaced I want ...
0
votes
0answers
12 views
How to store data from an excel sheet into an array so it can be called by an RFID scanner?
The excel data will have an ID number for the data for each row, and the same id number would be on the RFID tag. When the tag is scanned, the program should display the data specific to the ID ...
1
vote
2answers
39 views
Attempting to call an array and setting the value from a text file
Bear with me, this is a bit long. This class here is creating a student object:
public class Student {
String firstName;
String lastName;
int assignmentScores[];
int labScores[];
...
0
votes
3answers
71 views
Reading values to array, inside a loop
I am trying to build a program which allows a user to input an actors name and details (age+address) and also 2 films they've starred in. These films must be read into a main array in the main method, ...
0
votes
5answers
72 views
Parsing a string array in java
sNums = scanString.nextLine();
String[] num = sNums.split(" ");
for (int i = 0; i < num.length; ++i)
{
numbers = new double[i+1];
numbers[i] = Double.valueOf(num[i]); ...
0
votes
5answers
56 views
How can a user input an array of any length in java?
I'm writing a program in java that requires the user to input a series of numbers, for example 1 2 3 4 .. until the user decides to stop and press enter. Normally what I would do is something like ...
-7
votes
0answers
36 views
How to determine average of an array of integers and print the amount that were above that average [on hold]
I have to use one dimensional arrays to write an application that will count the number of days that the temperature is above average. It must read 10 temperatures from the keyboard and place them in ...
0
votes
2answers
38 views
int and long cast in loop for array
I'm trying to understand. What will happen as n passes from int range to long int range and why doesn't this pose a conflict for the compiler? I'm intending to use this to create an array of size n (I ...
0
votes
3answers
47 views
Java is this check for uniqueness sufficient?
double[] a = new double[size];
for (int i = 0; i < size; i++) {
double randomNum = Math.random() * 100;
a[i] = randomNum;
for (int j = 0; j < i; j++) {
...
0
votes
1answer
24 views
Create a class that contains an array of an object I just defined
Okay, so I just created an object called "house" that draws a house using
import java.awt.geom.Rectangle2D;
import java.awt.geom.Line2D;".
I now want to create an array that can recreate these ...
0
votes
3answers
42 views
Java Array of unique randomly generated integers
public static int[] uniqueRandomElements (int size) {
int[] a = new int[size];
for (int i = 0; i < size; i++) {
a[i] = (int)(Math.random()*10);
for (int j = 0; j < i; ...
1
vote
3answers
42 views
Can I avoid using regular expression to find even integer values from an int array?
To begin with I do not write code in java on a daily basis, though I am somewhat familar with most aspects.
I have an integer array with mulitple values present. I then take this array and convert ...
0
votes
0answers
19 views
Create logic and syntax operation to move the player and reduce bank balance in Monopoly game
I am in a struggle with trying to make a player move around the gameboard by using array in java. I also need a help with making methods to update some attributes to handle with bank balance. My goal ...
0
votes
1answer
34 views
A method to solve a word search in Java using 2d arrays.?
I'm trying to create a method that will search through a 2d array of numbers. If the numbers add up to a certain sum, those numbers should remain and all of the other numbers should be changed to a 0. ...
0
votes
0answers
19 views
Trouble with Caesar Cypher design
Here is a coding assignment I have. I'm having a really hard time understanding the parameters for this (keep in mind I'm a total coding noob and took this course with no background whatsoever). I ...
0
votes
6answers
50 views
JAVA: Trouble putting values into a toString method
My method locateLargest() as show below is a method to find the coordinates of my largest value in my array. I'm having trouble putting the return values into a toString method. I have no idea how ...
1
vote
2answers
25 views
How to transform a regular array into two dimensional jagged array?
I have a String array
String myArray [] = {"user1", "doc2", "doc5", "user2", "doc3", "doc6", "doc8", "user3", "doc 10" }
The meaning is that user1 has doc2 and doc5 ... user3 has only doc10 etc
I ...
0
votes
1answer
47 views
Anyone know why this method for linked list keeps on going forever?
I have this linked list method that is used to insert before, so it takes a node and puts it before the beforeNode. Currently it does that, but then it goes on forever and makes the linked list ...
1
vote
1answer
75 views
Java Array sort by means of a comparator
The complete code can be found at: https://skydrive.live.com/redir?resid=7B7D2F11B13EF9C9!54468&authkey=!AD4fD8sGgc7oJIE
This is part of the code:
g_sorted = 0;
for (int l_loop = 0; l_loop < ...
0
votes
1answer
26 views
Median filter of a pgm image
I have to write a program that replaces each pixel with the median value of it and its 8 neighbors. What I have will compile but when i try to create a new image im getting multiple errors. Help is ...
0
votes
4answers
36 views
Simplifying Multiple Line Array
I am still new to Java and was wondering is there a way to cut my array down to utilize a remainder operator to start a new line when 5 goes into a number and there is not thing left over? I have been ...
0
votes
1answer
45 views
Cant access the full array
I have a method which calculates total distance covered by a particular member which returns as a double array, like so:
public double[] getTotalDistances(){
double[] distance;
distance = new ...
0
votes
1answer
22 views
How can I create actions for a variable number of buttons?
I'm creating a user interface for a game that I have to do as a class project, and needless to say I'm not experienced with Swing.
I did learn about actionevents and whatnot for simple button pushes, ...
0
votes
0answers
22 views
Very large, specific 2d array for-loop returning null values in random spots
I have a huge double for loop to fill a 2d array, based on a very specific set of criteria. I'm displaying this 2d array in a JOptionPane; on some runs of the program, I get no "null", on others, I ...
-1
votes
3answers
41 views
2 dimensional array to string code java
For a program I have to write I am required to turn a 2 dimensional array of single digit intgers into a string of numbers separated by spaces. A test code is provided for me and when I run it, my ...
-1
votes
1answer
15 views
Represent execution time on graph in Java for different elements [on hold]
I've been working on implementing parallel versions of sorting algorithms (merge,quick,radix etc) and after doing them I'm trying to represent the efficiency of my implementation on a graph.
E.g., if ...