Tagged Questions
1
vote
1answer
28 views
Obtain Inner JSON Array Values
I'm attempting to get the values for the "filterInputParameters" array within the serviceResponseValue map. Right now I have attempted to iterate through the map but could only obtain the first level ...
-2
votes
1answer
35 views
Split string to array filled with null [on hold]
I am trying to do a loop where i am splitting a String into String[]
sumc is an arraylist, which is a global variable
cind and dbind is String[] and also global variable
for (int i = 0 ; i <= ...
-2
votes
1answer
54 views
Applying conditions to a String array using java?
Firstly I have an SQL statement when brings in a set of data shown below and its received as a resultset.
+--------------------------------------+
|Row A| Row B | Row C | Row D | Row E |
...
-1
votes
3answers
51 views
repeating a program with arrays
I'm trying to get my program to repeat, but it's not working out too well. This is what I have so far:
import java.util.*;//to use scanner class
public class ArrayDemo
{
public static void ...
-2
votes
2answers
30 views
Concat strings inside Array in SimpleAdapter [on hold]
I have following statement in Java (Android development):
ListAdapter adapter = new SimpleAdapter(
MainActivity.this, list,
R.layout.list_item, new String[] ...
-7
votes
0answers
28 views
How to put the data into the array - java
i'm working on project that transmits image through xbee.
here is the code when i receive the image.
main code:
ZNetRxResponse rx = (ZNetRxResponse) response;
for(int i=0;i<=500000;i++)
{
...
...
1
vote
6answers
76 views
Java's String concatenation doesn't work inside 'for' loop
Yes, I know Java's Strings are immutable, but still, that alone does not explain why this won't work for me...
I ran into this problem when I tried to convert an array of strings (String[]) to one ...
0
votes
1answer
25 views
Storm emitting array of integers and retrieving it
I'm turning an image to a 2D array of integers. Doing some process on that then I'm trying to emit the array in this way :
collector.emit( new Values ( scaledImageMatrix ) );
then I'm trying to ...
-2
votes
5answers
47 views
Arrays.sort throwing class cast exception
The Arrays.sort function throws ClassCastException in the following scenario:
public static void main(String[] args) {
Object[] obj = {
new String("string"),
...
0
votes
2answers
36 views
Reading in files from array of files [on hold]
I'm new to Java and am attempting to read in files from java, but I can't seem to figure out why this is happening. I'm getting IOExceptions and errors when I'm trying to read in the files. I just ...
0
votes
2answers
61 views
Populating a HashMap with an Array
So I tried finding a tutorial on how to do this but nothing gets this complicated. This is the first I am learning of HAshMaps so I am sure my solution should be easy, but I don't know how to do it.
...
7
votes
3answers
92 views
Array of arbitrary dimension as method parameter
I have a simple converter method for an array from boolean to int:
public static int[] convert1dToInt (boolean[] x) {
int la = x.length;
int[] y = new int[la];
for (int a = 0; a < ...
3
votes
4answers
119 views
Couldn't save an Integer in a Object Array
I want to parse an String from an Object[] into an Integer and save it at the same place like this:
public class ArrParseTest {
public static void main(String[] args) {
Object[] arr = ...
-2
votes
1answer
35 views
Passing structure to a method in Java
I have this function so far:
public void passSomething (String[] texts);
this accepts strings only, but what if I have to pass more string, numbers (structure)? Like in php for example
...
0
votes
0answers
20 views
scanning for next empty value in a 2d array and replacing values in the row
So basically, I need to search for the next empty value of an index (which is designated as 0), and replace the whole row with a variety of information. for instance, if there is a blank element in ...
4
votes
6answers
84 views
java function that work with objects and primitives
I'm trying to write a function that accept an array and return an array in different order.
It works with int, double, string, object or any object in an array.
Follow are the sample of the ...
0
votes
2answers
11 views
How to save dynamic 2D array imported from csv?
I am making a code importing CSV files into String 2D array.
Since I intend to apply this code for other CSV files also, which have different number of columns and rows, I should use dynamic array.
...
-5
votes
1answer
45 views
enhanced for loop (java) [duplicate]
how can i change out the for loop in this program:
public class deleteplz{
public static void main(String args[]){
String[] cdSporNavn = new String[4];
cdSporNavn[0]="fritjof i fjøset";
...
3
votes
1answer
48 views
Calculating the exponential of a square matrix
I'm trying to write a method that calculates the exponential of a square matrix. In this instance, the matrix is a square array of value:
[1 0]
[0 10]
and the method should return a value of:
[e ...
-1
votes
2answers
91 views
What does this code really mean?
I made a static method array searcher for int for some pratise to clear myself for making algorithm. I made the static method:
public class ArraySearcher
public static int integerSearcher(int[] ...
1
vote
1answer
60 views
Improvement of list comparison algorithm complexity
I have two arrays array1 = Array<List<Integer>> and array2 = Array<Integer> and I traverse array2. Then I try to find in which list from array1 the current item in array2 could be. I ...
0
votes
2answers
27 views
Map each value in a Java array (or similar) like in Ruby
It's been a while since I last used Java, so forgive me if the question is stupid. In Ruby, I use .map quite a lot. Is there something similar in Java or do I have to iterate over the Array?
In Ruby, ...
0
votes
2answers
71 views
Creating an Array of String[] from Notes Multivalue fileds
I am creating a JAVA method that returns an array of Strings, my method looks like this:
public String[] getReaders(String linkKey){
...
String[] rtn = ...
-2
votes
4answers
40 views
Checking for palindromes using array on ints, help (storing digits of long in array int)
Here is some code I wrote to check if a long is palindromic, using an array of integers. I did it like this to test my skills, (failed) so don't comment on better ways to check if a number is a ...
0
votes
0answers
22 views
HttpServletRequest parameters names as array like in PHP
I'm from PHP and I want to test Java for the web.
I'm use to do things like that in PHP :
<input name="input[items][0][quantity]" value="1">
<input name="input[items][0][variant]" ...
-1
votes
2answers
71 views
Int comparison with array in for loop to get no duplicate value
I am trying to make sure that the answer generated will not be duplicated in a maths app on Android. Here is the code I have:
If I initialise an array of person objects with this data
private int ...
-4
votes
0answers
60 views
Java Programming with Arrays [on hold]
Recently I got test to write Java program for:
here the input is string(eg. MAN or BAND etc..), and output should be integer
problem statement: A=0,B=1,C=A+B,D=C+B so on., program should return the ...
0
votes
2answers
48 views
java equivalent of dynamically allocated arrays in C++
I'm learning java after having programmed in C++ for a while, and I'm wondering if you can dynamically allocate an array in java as you do in C++.
Say in C++ we do:
int* array = new int[arraySize]; ...
0
votes
3answers
64 views
How to concatenate elements of an array into an integer
There is an array say arr with elements
6,5,1,0,9
I want an integer
a=65109
and
b=90156
0
votes
3answers
31 views
java.lang.NullPointerException upon access to an Imageview[] array - Javafx
I'm sorry if this seems trivial to you all, but I am still learning and I have looked through articles and tried several techniques...I could create each card image separately, but I need to learn how ...
0
votes
1answer
50 views
How to print out columns instead of rows?
alright so im making a program that prints out how many times the numbers 0-9 were input, its supposed to go on forever, until the user types a negative number, then its gonna stop the program and ...
1
vote
2answers
55 views
Why can ArrayLists store different object while arrays cannot?
Putting different types of Objects into an array will throw an ArrayStoreException, while putting different types of objects into an ArrayList works.
As far as I know, the ArrayList is built on top ...
-1
votes
1answer
28 views
Going through a JSONArray in Java
I've got a JSONArray that I pull from a server, it is a report of the emails I send to the server. My goal is to go through it, pick the one with a specific subject and print the "recieved" number ...
0
votes
1answer
27 views
Is there a way to store right angle triangle made of int ellements in a 2 dimentional array?
The problem comes when I have to give a specific number of elements in the column section [rows][column] because column is always changing acording to the line. The number of colums are dependent on ...
0
votes
2answers
42 views
how to print out the same name of an array element once
I am working on a budget app for practice. And I am using an array of objects and want to be able to iterate through an array and only print out an element of the same name once, to create a menu for ...
0
votes
1answer
46 views
Reading an array of text fields
So I need to make a Java program that can read in user input in text-fields. I was able to set up the array of text fields but reading in the input and storing the data in a new array is troubling me ...
4
votes
1answer
71 views
Create new instances of a class from an array of classes with Java
I'm trying to create an array of classes in Java. Not objects, but classes. Currently I have a class MyBaseClass and I extend three classes MyClass1, MyClass2, and MyClass3 from it. I store these ...
-5
votes
1answer
34 views
how to store value in two diamentional array in diagonal?
1 3 6 10
2 5 9 13
4 8 12 15
7 11 14 16
I want to store an value in this fashion? what should i do for the same?
want a java code for the same
-2
votes
3answers
81 views
How to remove preceding zeros in an array
I am practicing for my programming test and I came to a problem where I have to remove preceding 0's in my array. Suppose I have an array of [0, 0, 6, 7, 0, 3]. My result array should be [6, 7, 0, ...
-1
votes
0answers
34 views
Combinations of string array elements in Java [duplicate]
Suppose I have an array with elements arr = {'A' ,'B', 'C'}. I wants to create possible combinations of the array as: A, B , C, AB, BC, AC, ABC in Java
1
vote
6answers
49 views
Clarification on multi-dimensional arrays
This is my code and I'm trying to print the values of an array but I am not getting the proper output. Can someone show me where I am going wrong?
This is my code.
public class Arrrays {
public ...
1
vote
2answers
37 views
Common property for JButtons
I am new to swing core functionalities. I have experience in web designing. There is id for uniqueness and class for commonality.
<div class="x" id="div1"></div>
<div class="x" ...
-7
votes
0answers
39 views
How to convert an array into a linked list in java? - (Do not use java.util.LinkedList) [on hold]
I want to implement a method in java to convert an array to a linked list without using the java.util.LinkedList.
Please provide your inputs.
0
votes
0answers
36 views
Concatenating two arrays in java, returns nonsensical answer [duplicate]
public class Test{
static int[] concatenate (int[] a, int[] b){
int[] newArr = new int[a.length + b.length];
for (int i = 0; i < a.length; i++){
newArr[i] = a[i];
}
...
0
votes
2answers
65 views
Arraylist<Object []> to Object[][]
I am trying to create an ArrayList of Object[] from an Object[][] perform some changes and then getting a new Object[][] with the changes made.
However I get this compile error:
error: ...
3
votes
3answers
80 views
Removing duplicate digits in an integer
I have faced this program in Aspire System at Chennai while attending second technical round. They have give this program to me for removing duplicate digits in given integer without using arrays or ...
2
votes
3answers
72 views
Find missing element from one array comparing from other in single for loop
Is it possible to find out one missing element from one array that is not present in other array using single for loop in Java
e.g. a1 = {2,5,1,9,3,4} , length n+1
a2 = {2,4,1,5,3} , length n
...
4
votes
9answers
119 views
How can I select a value from an array?
How can I select a value from an array? Example is this String[] ans = {"+", "-", "/", "*"}; then I want to select "+".
public static void main(String[] args) {
String[] ans = {"+","-","/","*"};
...
3
votes
2answers
32 views
Java: insertion sort trouble with array size
I'm trying to write a sorting program that will ask a user what type of sorting method to use (insertion, bubble, selection) and then ask him to enter integers to sort.
I think I have everything ...
0
votes
3answers
47 views
Ordering array by a property in Java
I have an array of objects in Java. Let's say Product products[].
Each of those products have a price, for example, product.getPrice().
What's the best way I can order that product array by the ...