array 13 « array « Java Collection Q&A

Home
Java Collection Q&A
1.algorithm
2.array
3.Array Byte
4.Array Char
5.Array Convert
6.Array Dimension
7.Array Integer
8.Array Object
9.Array String
10.ArrayList
11.collection
12.comparator
13.Development
14.Garbage Collection
15.Generic
16.hash
17.HashMap
18.HashTable
19.iterator
20.LinkedList
21.List
22.Map
23.queue
24.Set
25.Sort
26.tree
Java Collection Q&A » array » array 13 

1. Inputting arrays to find the average    java-forums.org

Really. You don't even know how to write a class? Or a loop? Or a print statement? Or any other legal Java syntax. You might not know how to write the complete program but you should know how to do individual snippets. If you do then try building it up a small piece at a time. If you don't then go ...

2. Array Concept    java-forums.org

Hi all, I Have a sql which will retrieve many rows, all i want is how to store these each and every value what is retrieved at each loop in an array and later use each and value in array that is stored in different loop. only thing i know is i have to use global array. in this concept array ...

3. Array help please    java-forums.org

Hi there I have a scenario where a wildlife observer is looking for animals in the wild. The observer must enter a number 1-8 depending on the animal he sees. which could look like this 1 4 3 3 1 8 4 2 3 and so on I need to make an array with 7 animals. hippo, cheetah, buffalo, monkey, zebra, ...

4. if statement using an array. please help! :(    java-forums.org

In this code, I want to check whether the ward name is available or not. import java.util.*; public class test { private String arrayWard [] = {"a","b","c","d","e"}; //This is my ward array public test() { test(); // this is to call the method } public void test() { Scanner in = new Scanner (System.in); System.out.println("please put a/b/c/d/e"); String wardName = in.next(); ...

5. Histogram made with array    java-forums.org

Hi all, so I basically need help writing the code to make a histogram out of an array I have. It takes the grades inputted and stores them in the array: Java Code: public class Grades { public static void main (String[] args) { float result = 0; Scanner scan = new Scanner(System.in); int count = 0; float[] grades = new ...

6. Code to calculate mode using array    java-forums.org

Hopefully someone here can help. I have to write a code that does a few simple tasks, but is becoming really tricky. The code has to read an input file made up of integers. These integers range from positive to negative and include zero. Each integer has it's own line. The code must read this file, convert it into an array, ...

7. Array for counting from 1 to 100    java-forums.org

Here's the assignment: Write methods for the following: a)Find and return the total sum of numbers stored in an ArrayList. b)find and return the maximum number from the ArrayList. c)Find and return the minimum number from the ArrayList. d)Find and return the mean of all the numbers from the ArrayList. Write a tester class that creates an ArrayList of numbers. Add ...

8. Help with array for "students avg test scores."    java-forums.org

Hello everyone, Java is still kind of Greek to me and I just need help with my assignment. I'm having a little difficulty starting. I know I need to use a for loop but I don't know how much arrays I would need. Below is the problem that I have to code. Thanks in advance for all the help. Problem: From ...

9. Car Simulation (Array)    java-forums.org

10. I want to make an array in a method...    java-forums.org

This is going to be an array of objects that will be created inside my "startRoom()" method. The idea is that this method looks at a map I've already made, and counts how many of an object to put in. Then the method makes an array, called "objectsInRoom[]" and the length is how many objects were counted to be in the ...

11. Need an array    java-forums.org

Hey all. I am new to Java and trying to work on an assignment that will be due in a couple days. It says I need an array. I have read multiple pages as well bought a book. I understand how an array works but coding it is a little difficult. The assignment is as follows: Modify the Inventory Program so ...

12. Help with two arrays    java-forums.org

Im having major problems with java. I have to have a program that reads name and numbers into two arrays of Strings. Then the program will print out the two arrays in a meaningful way. Then the program will set up a loop and inside the loop, the program will print out a menu as follow. 1. Check a name 2. ...

14. Array cannot be resolved    java-forums.org

15. Instancing methods in arrays possible?    java-forums.org

Hello, Is it possible to instance methods in arrays. I did the following and it doesn't work... am I doing something wrong or trying to do something impossible? I want to make an array method to store and retrieve data. I realize there are easier ways to do this. My output is all 5s so the variable unit isn't getting instanced ...

16. Help with Array    java-forums.org

I'm working on a project in my Java 2 course. I have the first two parts down but the final part has me stumped. I seriously think I am just over thinking this. I am being asked to create a class that handles large array values (we have created a class that generates fibonacci numbers and stores them in an array) ...

17. Arrays    java-forums.org

Hello everyone So i'm kinda new at java (been learning it for only 2 weeks) So basically, my probleme is that i want to give the user a possibility to somehow change the limitation of the array. Now i know that it is not possible, as an array is "final", but it's hard to believe that there is no way to ...

18. help writing array method    java-forums.org

19. Using Arrays and Overloading Methods.    java-forums.org

I am currently in an AP computer science class where we learn how to program in Java. Our assignment is as follows "Use method overloading to write a program that will test to see if the parameters sent in are equal. The program should use loops to allow the user to enter in 2 or 3 integers and call the appropriate ...

20. array multiplication with single double    java-forums.org

21. Array Programming Assignment - Digit Counter    java-forums.org

The following are the directions for this assignment: For this assignment you are to print a table that gives frequencies of the digits 0 through 9 in a typed English text. To keep things simple and concrete, your job will be to print the digit frequencies for multiple lines of text you enter from the keyboard. More specifically, you program should ...

22. help with multidimesional array qn    java-forums.org

b) Given two equal sized double arrays : X, Y initialized with some non sorted numbers, and a third equal sized boolean array Z . Write a Java method to check the equality of corresponding elements of array X and Y elements , and put the result into the corresponding index element of boolean array Z . [10 marks]

23. Problems calling methods with arrays.    java-forums.org

I decided to write my first genetic algorithm today for fun, but I am getting many ".class expected" errors that seem to have something to do with the way I use arrays. (I've never used arrays like this before, so there's probably something really simple that I'm not understanding about them.) The goal of the program is to create a 16 ...

24. Trouble with arrays Help    java-forums.org

The instruction for my assignment is the following Create a class to maintain a personal budget for a year. The name of this class is Budget. The data your class will need, at a minimum, are: an array of categories (like Tuition, Food, Clothes, etc). You should have at least six categories. You can use your own expenses as a guide. ...

25. Help with arrays    java-forums.org

I have some java methods that I need to keep in place, written by another person. The program will read in a user given file, which is a series of data associated with a person's name. This data is given in a semi-colon delimited line, like so: Professor Oak;4;6;9;0;10;6;10;9;10;9;6;10;9;8;6;9;10;10;6;6; 7;64 Where each delimited item corresponds to: Name, Quarter 1, Quarter 2.....Quarter ...

26. Array Help    java-forums.org

Hello, I am trying to create a method that will out put 3 random variables consisting of either 7, Cherry, Space, or Bar (it's part of a slot machine). I am new to arrays and I am not sure out to put an out put of an operation and put it inside an array. The problem I am having is at ...

27. Having some array trouble    java-forums.org

The full compiler message would help. And an indication of what line of your code it is referring to. Note: use "code" tags when posting code or compiler messages. Put [code] at the start of the code and [/code] at the end: that way the formatting is preserved when the code is rendered on a web page. On a good day ...

28. identical arrays program    java-forums.org

I am getting this output with the code below Enter list1: 5 2 5 6 6 1 Enter list2: 5 5 2 6 1 6 Two lists are identical I have to press enter twice after the first number and once after each additional number. I need it to allow me to enter all six numbers then press enter for each ...

29. Trouble with arrays..    java-forums.org

Ok so here is my problem. I have to write a program where a user can input UP to 25 test scores. The program will then display the scores in a list, then the TOTAL number of test scores that were entered, and then display the highest, lowest, average, etc. I have a lot of it done, but now I am ...

30. If statements and arrays, problem    java-forums.org

Hello, just started with JAVA programming and need some help. I'm from sweden and its swedish if you dont understand some sentences. Its a start for yatzy and i know it is not optimized , so to speak. But i would like to advance in my own speed but would gladly get help with this problem. Java Code: public class HEj ...

31. Array question    java-forums.org

Hi I am to design a hunters game in java which is going to be run from cmd(strictly no GUI) I have created a 12x12 array which is my board, I need to move my character using keys, and make a Hunter(NPC) move towards [0][0] from [12][12]. How do I store each players and hunters coordinates (To check for collisions etc)? ...

32. How do you make an array of arrays?    java-forums.org

public class Budget{ ///////////////fields//////////////// private String expenseName; int expenseAmount[] = {1000, 2000, 3000, 4000, 5000, 6000}; int monthNumber[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; int i=0; // this is arbitrary. Never hard code numbers unless that number is never going to change. in that case you make a variable and define it. int month_num; ...

33. return position in array    java-forums.org

Hi, my code below fills an array with random numbers and asks the user to guess if a number is located in a particular column. If the number is in that column it will print true, if not it will print false. If the method check is true how do i return the position where the number was located in the ...

34. Good ol' arrays! Help O_O    java-forums.org

Good ol' arrays! Help O_O Okay guys... I'm in my only CS class I have to take and I'm almost done and barely keeping my head above the programming water! So here's my assignment: Proff. gave us a file to download and input into the java program (got that :)) and in there are names of 'people' who have ...

35. Help with an array    java-forums.org

36. help with arrays    java-forums.org

Hi everyone, I am using JOptionPane input method to ask the user to enter a word. I am doing this in a while loop, which ends when no word is entered into the window. What I am trying to do is store all the words entered into the window into an array. I am wondering if this is possible and if ...

37. 3D array to .txt    java-forums.org

Hello, I am currently making a 3D game for a computing project I am undertaking, but i am stuck on a problem I assumed to be easy. I will be having a couple of set maps the user can play on, and all objects and entities to be placed on the map will be given a x, y and z co-ordinate. ...

38. Arrays made from user input    java-forums.org

Hey all, I'm wondering how I'm supposed to get a variable list of input values into an array. I know that the method header "public methodName (int ... list)" can be used when the list is known, but can this be used when the list is user input? Basically, I want the user to input a set of integers; any number ...

39. FileReader and calling a method which gives back an array    java-forums.org

Hey there, I know the title is stupid, but I didn't know how else to call ist. I'm trying to write a method that reads from a file. The file contains of 5 rows and a lot of columns. I wanted to read in the 5 rows into an array. As I only new the method readLine() but nothing of rows, ...

40. Help with arrays    java-forums.org

Hi, I'm writing a program that is supposed to accept a candidates number and number of votes and then print them in (number, votes) form. I've got it pretty much figured out except for one part where I'm supposed to disregard an invalid vote (e.g. -999). I've tried a if/else code but I'm not sure how to make the if statement ...

41. Reading input and storing into array    java-forums.org

I am having trouble doing so. I am required to have the user enter integers seperated by commas and I need to then store only the integers into an array. I am new to java. I tried the skip method but I don;t know how it works. Here is what I have so far. Thanks in advance! int numbers; Scanner keyboard ...

42. Calculating Average using Arrays....help!    java-forums.org

I've been stuck on this for many hours now. I'm trying to allow the user to input 10 numbers. Then the program is to add up the numbers and output an average. I'm baffled by what I should be doing for the average part. Below is my code, followed by my output. I actually only have to write out the logic ...

43. I need help writing an array backwards    java-forums.org

import java.util.Scanner; public class DecimalArray1 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); double[] myList = new double[6]; System.out.println( "Enter a decimal number: "); int index = 0; while(index < myList.length) { myList[index] = scan.nextDouble(); index++; } System.out.println("\n\nYour values unsorted; "); index = 0; while(index < myList.length) { System.out.println(myList[index]); index++; } } }

44. array help    java-forums.org

45. Array Issues    java-forums.org

Hi everyone, I just have a quick question that probably has a really simple answer too. I've only just begun using arrays and I was wondering if it was possible to have an array that has 5 values initialised but also has room for it to be expanded, for example 15 extra positions giving a total of 20 with the initialised ...

46. Help with arrays tutorial program please!    java-forums.org

Sup! For my course i have to write a java program that will make you enter ten integers and it will then print out the smallest integer! The problem im having is that it works every time except for when i enter "10,9,8,7,6,5,4,3,2,1" And it will say that 5 is the smallest integer! Please can you guys help me out as ...

47. Can't seem to get my array table to show up :(    java-forums.org

Hi guys, here's a link to a section of my code: >>>> Link Removed<<<< Please post code here Whenever i run my program, the inputs work, but I get this error saying "Exception in thread "main" java.lang.NullPointerException at game.printGrid(game.java:66) at gameUser.main(gameUser.java:25)" In my user class game, I call the method from the other class to show output. Here is my code ...

48. Arrays    java-forums.org

Hi everyone, I was wondering if someone could give me a hand with my problem. So I have set up an array that has 20 positions available in it (0 - 19) and I have initialised values in the first five positions (0 - 4). Now my issue is that when I use a scanner to input data into a field ...

49. Shifting an Array    java-forums.org

Hello everyone, I started learning Java a few months ago online and using the book "Java: A Complete Reference" and "Java for Dummies". I am a beginner and having a hard time learning Java (I only know some basics of HTML and PHP). At this moment I am trying to shift an array one value to the right. I managed (with ...

50. A problem with using an array    java-forums.org

package create; public class Deck extends Card { private Card[] singleCard = new Card[52]; public Deck() { char suit1 = 'X'; String rank1 = "X"; int counter = 0; for(int i = 0 ; i < 14 ; i++){ /* some switches to assign correct suit/card rank go here */ singleCard[counter].modifyCard(suit1, rank1); /* HERE */ counter++; } } } /****************************************/ public ...

52. cant understand arrays (one doubt). plz help    forums.oracle.com

Was just going over this the other day myself, here is what I found "Irregular Arrays When you allocate memory for a multidimensional array, you need to specify only the memory for the first (leftmost) dimension. You can allocate the remaining dimensions separately. For example, the following code allocates memory for the first dimension of table when it is declared. It ...

53. What can we typecast an array into?    forums.oracle.com

i really couldn't tell you.. it's a question off a previous exam for college and i have no clue what he's asking. so far i have: - - Four categories of primitive types Whole-number (integer) types Floating-point types The character type The boolean type An array may be converted to the class Object, to an interface - ...

54. Java arrays    forums.oracle.com

System.out.println("Enter a score or -1 to terminate"); scores[count] = input.nextInt(); //loop until the user enters -1 while (scores[count] >= 0) //total= total + scores[count]; count++; System.out.println("Enter a score or -1 to terminate"); scores[count] = input.nextInt(); }//end while //calc total of scores System.out.println("The scores are"); for (int x=0;x

55. array problem    forums.oracle.com

56. Array problem    forums.oracle.com

damn.. post the last post by mistake... just a quick scan at the code.. that looks wrong.... check your closing bracket for your loop.. You have to populate your list before u do the scan.. and NOT scan while u are populating the list... another point to make is.. for binary search to work, the list has to be ordered... another ...

57. ned help in array...    forums.oracle.com

No. You do your own homework. Write down the steps you would go through if you had to do this by hand, then transform those steps into code (hint: you'll probably want to use a for-loop, or two). BTW, it would be better to create a "Country" class to contain data about the country.

59. Array!    forums.oracle.com

Hey! Thanks for your time! Here the whole excersise and the methods i have trouble with. /* * Floor.java * * Created on August 14, 2008, 11:45 AM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package first; /** * * @author student */ public class Floor { private ...

60. Arrays    forums.oracle.com

/* * Staircase.java * * Created on August 14, 2008, 12:07 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package first; /** * * @author student */ public class Staircase { private String streetName; private int streetNumber; private int[] numberOfOwners; private Floor[] floors; private int size; private int ...

61. Transpose Array    forums.oracle.com

62. array not recognized    forums.oracle.com

package LibraryAssignment; import java.util.ArrayList; /** * * @author Matthew */ public class Library implements Cloneable{ private Library(){ ArrayList masterList = new ArrayList(); LibraryAssignment.Author author = new LibraryAssignment.Author("Mike", "Hancock"); masterList.add(new LibraryAssignment.Book("123456789", "This is a book", "Horror", author)); LibraryAssignment.Author author2 = new LibraryAssignment.Author("Shaun", "Westerhof"); masterList.add(new LibraryAssignment.Book("987654321", "This is also a book", "Mystery", author2)); for (int i = 0; i

63. Method calls and arrays    forums.oracle.com

64. hi Array    forums.oracle.com

yes most of them check out arraylists on the java api main advantage i find from using arraylists is that you dont need to specify a length to get you goign use the following commands to add to an array list - myarraylist.add(put your value here) to get a value from an arraylist - myarraylist.get(int which place is your value in ...

65. Array Problem    forums.oracle.com

Hello Cotton, Thanks for pointing that out to me about the (int) issue with the String. I do know better than that after all you've taught me better than that. The issue here is that I wrote it all out, compiled it without any errors and it ran fine. But, then I wasn't paying attention and was cleaning out the file ...

66. array inputs    forums.oracle.com

/* Compare the user input to the unique numbers in the array using a for 31 statement. If the number is unique, store new number */ 32 33 /* add the user input to the array only if the number is not already 34 in the array */ 35 if ( !containsNumber ) 36 { 37 /* Write code to add ...

67. Array    forums.oracle.com

68. tokens and arrays    forums.oracle.com

1. Figure out how many tokens you have 2. Create an array for holding that many Strings 3. Every time you read a String, add it to the next position in the array 4. Print it OR 1. Create an ArrayList 2. Every time you read a String, add it to the ArrayList 3. Print it.

69. Array    forums.oracle.com

70. I need some help with arrays    forums.oracle.com

Hello, Sorry for being blunt, but I need a beginners version answer of how to write a method that accepts an array (of integers or string type does not really matter) as an argument and I need an example of returning an array from a method. I am a student, beginner with Java, and I have a couple of ideas to ...

71. array help    forums.oracle.com

Enter salesperson 1's weekly sales, or z to stop: 1000 Weekly Pay for Salesperson 1 is $ 290.00; Enter salesperson 2's weekly sales, or z to stop: 2000 Weekly Pay for Salesperson 2 is $ 380.00; Enter salesperson 3's weekly sales, or z to stop: 3000 Weekly Pay for Salesperson 3 is $ 470.00; Enter salesperson 4's weekly sales, or z ...

73. arrays, what am I doing wrong?    forums.oracle.com

74. initializing an array question    forums.oracle.com

if i wanted to initialize elements of an array and get input from the user of how many there will be. where can i find some info on this? basically instead of initializing 0,1,2,3, and so on i wanted to do it in a for loop, but i have tried it a couple of different ways with no luck. maybe you ...

75. signle dimensioned arrays    forums.oracle.com

76. Finding duplicates in Array    forums.oracle.com

java80 wrote: I wrote this test program to find duplicates and now I wonder how can i change my program to follow the above said 2 approaches: You already have achieved b. The integers must be stored somewhere and you don't use any additional storage. The naive approach gives an O(N*N) algoritm but by first sorting you've changed that to an ...

77. Help with Arrays, Round 2    forums.oracle.com

78. Arrays Help Please    forums.oracle.com

I want to pick some apples off the tree but first I will need to make a box to put the apples into. After I have made the box, how many apples does it contain? In your code your array is just a "box" that can contain some objects. After you have created the array it is empty. The objects are ...

80. Beginner question regarding switch statements with arrays....    forums.oracle.com

It's not clear to me what you're trying to accomplish. And since you're limited by the assignment, it's hard to know what your options are. java.lang.Character has some useful methods to determine things like case. You could (maybe) use switch statements over boolean return values from those methods, I guess. Or maybe you could use Character.getType and then create a switch ...

82. How to overwrite an array?    forums.oracle.com

You've been posting this question over and over and the drill should be familiar to you by now: 1. Posting a snippet like that isn't really helpful to forum readers. For one thing, the fact that your code has such a trivial error in it makes you an unreliable reporter. Why should we believe what you claim? 2. Once again, if ...

83. Array    forums.oracle.com

For the array [2, 3, 1], the last time through the i loop, i will equal 2. Then the j loop runs. The first time the j loop runs, j will equal 1; and the last time the j loop runs, j will equal 2. So, is scores[2] <= scores[2]? Yes. So yesorno gets set to true the last time through ...

84. Help! Can you help me write an array?    forums.oracle.com

85. Tridimensional array.    forums.oracle.com

86. array help    forums.oracle.com

greater = price[x] += average; lessthan = price[x] -= 5; System.out.println("The total of all prices is " + "$" + sum); System.out.println("Prices less than $5.00 are " + "$" + lessthan); System.out.println("The average of all prices is " + "$" +average); System.out.println("Prices greater than average are " + "$" + greater); }}} although I don't get any errors, it's not displaying ...

87. Array    forums.oracle.com

break; case 2: g.fillOval(a+10,60,15,15); g.fillOval(a+70,120,15,15); ping = 0; wak = 0; ijsbeer = 0; totping = totping + ping; totijs = totijs + ijsbeer; totwak = totwak + wak; break; case 3: g.fillOval(a+10,60,15,15); g.fillOval(a+70,120,15,15); g.fillOval(a+40,90,15,15); ping = 4; wak = 1; ijsbeer = 2; totping = totping + ping; totijs = totijs + ijsbeer; totwak = totwak + wak; break; case ...

88. I need an Array in my JAVA CODE    forums.oracle.com

Two Write a Java program without a graphical user interface that calculates and displays the mortgage payment amount given the amount of the mortgage, the term of the mortgage, and the interest rate of the mortgage. In this program, hard code the amount = $200,000, the term = 30 years, and the interest rate = 5.75%. Insert comments in the program ...

89. How to expand an array    forums.oracle.com

String strTest= "a,b"; String[] aryTest= strTest.split(","); //Now aryTest[0]="a"; aryTest[1]="b"; //Next, I want to expand the array for(int i=2; i<4; i++){ //I know this line doesd NOT work. Just for demo purpose aryTest=""; } } //Final aryTest result should look like this --> aryTest[0]="a" aryTest[1]="b" aryTest[2]="" aryTest[3]="" } How can I achieve it?

90. Best way to handle large arrays    forums.oracle.com

I use many large arrays to keep track of some weather data. I would say about 20 double[] xxx = new double[365]. This takes up quite a bit of memory and I am trying to come up with a better way to access the data from them rather than leaving the large array's in memory. I was thinking I could just ...

91. Help with array sum    forums.oracle.com

Hello! I have a little problem with getting the sum of an array. I want to get the result of adding all the array and get the sum. My solving on this now is to do like this: int [] v = {10,20,30}; sum = v[0] + v[1] + v[2]; But I'm sure there is a smoother way than this. I ...

92. Array expansion method not working?    forums.oracle.com

93. A question about arrays (brace yourself this is a long post)    forums.oracle.com

what's your question? is it as vague as "am I doing this right?" or "why is my output not what I think it should be?" personally, i'm not willing to invest the time to even bother reading something like this. i guess you'll find out how typical i am. i'd recommend that you boil this down to a succinct question or ...

94. Problem with arrays    forums.oracle.com

95. Array problem    forums.oracle.com

96. Standard Deviation and Mean of an Array    forums.oracle.com

97. 2 Dimmensional Array    forums.oracle.com

98. DotNetFromJava array problem    forums.oracle.com

99. Simple array    forums.oracle.com

100. sizable array    forums.oracle.com

More complicated to use an ArrayList? NO. Using an ArrayList, you can add as many objects as you like and that's it (providing you don't run out of memory). All the resizing is done for you. Using an array and resizing it yourself, you need to continuously check to see if the array is full and if it is create a ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.