Tagged Questions
0
votes
0answers
6 views
Client and Object Class outputting values
I have an object and client class created which prints coordinates in order of their distance from the origin. The client class asks the user how many dimensions they want the array to have (x,y or ...
0
votes
1answer
18 views
Try to use an array to create a new object from a class
I am trying to use an array to create a new object in StringInstrument class. Instead of StringInstrument ukulele = new StringInstrument(); I put StringInstrument instrumentList[i] = new ...
-1
votes
0answers
32 views
Java: How to reverse a subarray of an array
I have an array of elements, and I wish to reverse the order of elements between indices i and j .
Example: Let the array contain elements A,B,C,D,E,F . Calling the function reverse(array, 1,4) ...
0
votes
1answer
10 views
Create Instrument Class (Dealing with arrays and methods)
The array with the names of strings of the instrument is a required field in the Instrument class, but in order to simplify the program, I will accept solutions in which tuning of an instrument is ...
1
vote
1answer
43 views
Can I cast an object to a string from an object array of strings. Getting classCastException
I'm probably being very silly, but it's driving me nuts. I have searched around but am relatively new to programming and am in over my head. Please help if you can! the bar parameter is taking an ...
1
vote
4answers
46 views
How to get part of array elements by user input using a loop
I am creating a program that takes various double arrays and displays them. The array is 10 elements and I am asked to get the values for elements 2 through 9 from the user input by using a loop. I ...
1
vote
2answers
54 views
How to fill my array from another class?(Java)
This is my program that makes some calculations to a numbers into the array named "initialMarks". However I would like to fill the initialMarks array from another class using scanner.Could you help me ...
-4
votes
0answers
42 views
How to write a function to count the number of occurances for a number in an array? [on hold]
Write JavaScript program according to the following:
a. Define a JavaScript function occurrence(anArray,num), that takes an array anArray and a number num as arguments. The function returns the ...
0
votes
6answers
61 views
Performance primitive Array vs ArrayList
I want to know if there is a difference in performance if I use a primitive array and then rebuild it to add new elements like this:
AnyClass[] elements = new AnyClass[0];
public void ...
1
vote
4answers
55 views
I want to find a value from an array
Here's my java code:
import java.io.File;
import java.util.Arrays;
public class mainClass {
public static void main(String... args) {
File[] files = new File("%appdata%").listFiles();
...
0
votes
1answer
62 views
Java game - run code sequentially in the game loop
I am creating a Java game within which the user can enter the commands of up, left, right, or down to move the character in that location for a certain amount of pixels. Within the Player class I am ...
0
votes
4answers
29 views
Storing References to Objects of Different Classes
I currently have two classes that I create objects from. I need an array that will store references (pointers) to these objects. Of what type should the array be?
ArrayList<Class1> visableObjs ...
0
votes
8answers
70 views
arrays inside of the list
I tried to find what's wrong with this simple code, I tried to search on this website for sample but could't find it.
I want to create list of arrays. So when I call myList.get(0) it will output ...
0
votes
4answers
59 views
My method returns the same value for each value in the returned array
So.. In my program I have built a method which takes two values from an array and multiply them and after that it has to hold the value into an array.Then I do this again, but instead of saving the ...
-1
votes
0answers
32 views
In an Android app, the content of an static ArrayList vanishes(= disappears) [on hold]
We have a lot of code and it's really messy and we can't show it.
Everything works perfect, then when we add the code that reads from a JSON-file from the Internet it works perfect but then at a ...