array 18 « 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 18 

1. Array question.    forums.oracle.com

Hello all! I am writing a simple code (since im new) and i want to use array to group seven items. So my question is, is it possible to add the content within individual array? Like: ex= mathnum[0] + mathnum[1](making believe that they have the # 1 in each) ex= 2?? Thanks in Advance P.S Im wondering how can i have ...

2. rotate arrays    forums.oracle.com

Like I mentioned in my post, the loops will reflect and/or rotate depending on which way they go. Instead of assigning the values to the new array from 0 up to 4, go from 4 down to 0 (or maybe one of the other dimensions - I need more coffee before I can work out things like that...).

3. ARRAYS    forums.oracle.com

4. array question    forums.oracle.com

Hi all I have an array which looks something like this: [1,1,1,1,1,2,2,2,2,2,2, ,3,3,3,3,3, 4,4,4,4,4,] It could also be the case that I have [1,1,1,1,1,3,3,3,22,2,2,4,4,4,] I just need something (maybe another array) which summarises the contents of the original array eg [1,2,3,4] ie drops all the multiple observations. What's the quickest and simplest way to do this? Many thanks. Dan

5. Shapes in 3D Array    forums.oracle.com

6. Creating special Array    forums.oracle.com

Hi, this is my first post here. I have been using Java for a few classes at Texas A&M and always seem to get stuck on the same and simplest steps in my programs. I have a program where input is taken from a file about students. Then information about students is assigned, and by user choices either sorted, displayed , ...

7. two Dimesional arrays    forums.oracle.com

8. Array plus field?    forums.oracle.com

I'm sorry for the title but I have no idea how to properly explain what I'm trying to achieve. In my program I have a class called Ship. Inside that class I have a field defined as: private int[] weaponSlot; I also have: private boolean isFiring; Now, I have a method that queries isFiring but I need to "attach" it to ...

9. Rotate an Array in Java    forums.oracle.com

I'm sorry, can anybody help me to find out the algorithm of this one by using while loops? The array has 7 elements int number[7]={0,1,2,3,4,5,6} Rotate the numbers in the array. The first number becomes the second and the second number becomes the third, ..., and the last number becomes the first. e.g. 0 1 2 3 4 5 6 => ...

10. Help me with array    forums.oracle.com

sowndar wrote: I know basic of java. Irrelevant. Somebody gave you some very good advice--a link to follow. If you had bothered to follow that link and read the excellent advice provided there, you would have seen the following: # Work through the task the program is going to have to do using paper and pencil. If necessary, reduce the problem ...

12. Help with array    forums.oracle.com

I dont think you yet understand the question assigned to you. I think its best re-read the question and work out the answer with paper and pencil using a simple example before trying to code it. For example, given an empty array with 3 elements such as array[3], what should the function return. It should return a populated array that is ...

13. HELP! - How do I get header columns on this array???    forums.oracle.com

HELP! - How do I get header columns on this array??? Posted: Jun 30, 2010 6:31 PM Reply I am supposed to have this output with headers (Salesman1, Salesman2, etc) along the top and (Product1, Product2, etc) along the left side. I can get the array to print out but not headers. I took some of the recurring code ...

14. java array    forums.oracle.com

Hi, I am very new to programming. I try to make a java array and I need to knwo how can I give some values to it. e.g. public class Test { public static void mai (String arg[]){ int[][] x = new int[7][3]; for (int i = 0; i < x.length; i++){ x[]=i; x[0] = i; System.out.println(x); System.out.print(x); } } } ...

15. Array Question    forums.oracle.com

Hi guys, Is it possible to do the following thing with arrays: Let's say we have 3 elements in array1 (2, 4, 5). Now what i am trying to do is, Math.pow all the elements in array1 and save it in array2. So i just wrote: Math.pow(array1[0], 2); Math.pow(array1[1], 2); Math.pow(array1[2], 2); and then tried to: array1[] = array2[]; Whenever i ...

16. an array of Sets    forums.oracle.com

17. need help with array    forums.oracle.com

no! its just i cant think of any method which can be applied here! I can manage user input but i cant fig out how i will use this to get the result. and as this in not a predefined maze so it is making things more complicated. ( i was thinking about using if statements but still stuck with how ...

18. Reshape Java Array    forums.oracle.com

srikanth.kannan, welcome to the forum. Please don't post in threads that are long dead and don't hijack another poster's thread. When you have a question, start your own topic. Feel free to provide a link to an old post that may be relevant to your problem. I'm locking this thread now. db

19. randoms in array    forums.oracle.com

hi everyone .. i wanna store random numbers in an array then ask the user to guess it .. and compaire with the random array well am stuck at the array part . cant get it to work at all .. can anyone help pls .. just tell me how to store a randoms in array with for loop .. then ...

20. creating array by loopsfor    forums.oracle.com

21. Help with an Array problem    forums.oracle.com

k. I can do that. What if the user wants to enter 6 integers and then enters a negative to end entering integers but still wants the sum and average of the integers that were entered? Also, I kept the keepRunning set to true so the user can continue to enter integers as long as s/he wishes. Thanks for your help. ...

22. array    forums.oracle.com

23. Getting user input and putting into Arrays    forums.oracle.com

Array use always requires an index and there's no way to tell an array to "just put it in the next free space". That's what Lists are for (they also resize themselves as needed unlike arrays). So if you want to fill an array, you'll have to keep track of the free spot yourself and increment it every time you store ...

24. Help with an array please    forums.oracle.com

1) (A1) appears each time instead of (A1), (A2), (A3). This relates to the (nextAnswer + 1) part of the println statement. I've initialised nextQuestion = 0, so (nextAnswer +1) will always be 1. I can't see how to fix that? 2) Why am I getting each answer 3 times? I think it's something to do with my use of ANSWERS.length, ...

25. Questions missed array question    forums.oracle.com

26. need help with array!    forums.oracle.com

Well, in your makeMissedArray() method you probably want to initialize the missed int[]that you declared near the top there. Now you're trying to create a local variable which for one is an int and not an int array, so it's not even syntactically correct. As for the questionsMissed() method, what do you think it should return?

27. Initializing 3D Arrays    forums.oracle.com

How are you wanting to load those into a 3d array? If you have a text file like numbers.txt and you want to scan in numbers like you listed. Example: 1 2 3 4 5 5 4 3 2 1 4 2 3 1 5 3 1 4 2 5 2 5 1 4 3 And you want the array to ...

28. i need help points and array    forums.oracle.com

i need help points and array Posted: Apr 10, 2010 8:09 AM Reply i'm in a java class and i need major help with this This is the first part. We want to specify the coordinates (i.e., x and y coordinates) of a point in the two dimensional space (i.e., xy coordinate system). Point x: double y: double + ...

29. I'm having a problem with an array - misunderstand    forums.oracle.com

1) a method called letterGradeStats() that outputs a) The title: ?Letter Grade Distribution? Then print the total number of letter grades (e.g. A?s, B?s, ..., F?s) issued to students. The output must be formatted as: + ? = ? + + Output one letter grade per line. Leave a blank line between the ...

30. Arrays: Multiplying to make another array.    forums.oracle.com

{color:#993366}I need to generate a y coordinate based on the x coordinate (x1) of a circle with a radius of 1. So far I have this code but I cannot generate an array for my y coordinates. Any hints/tips would be appreciated. btw I am using the quadratic formula to find my y.

31. Arrays: Max/Min and Formatting.    forums.oracle.com

That's because you create variables "min" and "max" which represent nothing in particular (except the min and max possible values for integer, and which are thus extraneous) and compare those to the values you're really looking for. As an example, what you're doing is sort of the following: Try to find the tallest person in the room. Create a yardstick that's ...

32. Array out of bound - weird    forums.oracle.com

i < 6 means the loop will continue executing as long as i is less than 6. Once i reaches 5, the loop will break. If you used intarray.length there wouldn't be an ArrayIndexOutOfBounds exception, but nothing would happen to index 0, as you've missed it. Edited by: xcd on Mar 23, 2010 3:11 PM

33. Array Example Not Working    forums.oracle.com

34. Question with Array    forums.oracle.com

35. Arrays    forums.oracle.com

I have an array of words (amount of words vary every time the programs runs) and i have to sort them into groups base on their size, then i have to print the 3 largest groups, what is the best way to store the groups. PS if the groups are to be store in arrays then you have to allocate different ...

36. 3x3 Slider Puzzle 1D Array    forums.oracle.com

1. Acquire an image 2. Divide image into NINE separate images a. You will have a TENTH image that will represent the ?removed? space 3. Create TWO 2-D Image arrays a. One array will store the correct images as reference (use the array index as coordinates for the locations) b. One array will store the images mixed up 4. Create ONE ...

37. Array    forums.oracle.com

38. basic array help    forums.oracle.com

39. Array out of bounds?    forums.oracle.com

okay. I think i get it. If I call the array nums [10] then I can only control nine values right? (0-9) Would it work if I called the array nums[11]? That way I would have access to 10 variables. But then the user would have to enter 11 values, and I only need 10. o.0 My head hurts.

40. Array Input    forums.oracle.com

IronAces wrote: As you can see, I have set predefined places for the user input to go, but what happens if the user inputs more than 6 elements? it obviously wont work. You have the following choices: 1. Only allow a fixed number of inputs. 2. Allow as many inputs as the user wants, and if he enters more than your ...

41. Problem with simple array coding    forums.oracle.com

import java.util.Scanner; public class Unique { public static void main(String args[]) { Scanner input = new Scanner( System.in ); int[] number = new int[5]; // Create an array of five elements int count = 0; //number of uniques read int entered = 0; // value of entered while (entered < number.length ) { System.out.print( "Enter a number:" ); entered = input.nextInt(); ...

42. Inline Array declarations?    forums.oracle.com

Let's say I am trying to call the method declared below... foo(int[] iParamaterArray) I remember seeing somewhere that I can declare arrays like this: int[] iArray = {0,1,2,3,4}; So I would think I could do this foo({0,1,2,3,4}); Now in particular case I'm trying to pass an Object[], but nothing is working. I know I'm making some stupid little mistake. What gives? ...

43. Array creation help    forums.oracle.com

44. Question about an array    forums.oracle.com

Did you go through the array tutorial? [http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html] If not, you need to do so. If you did, then what in particular do you not understand? Do you understand how array index access works? That is arr[0] and arr[0][0]? Do you understand how to set a value? I don't know what to explain to you that's not covered in the tutorial. ...

45. array of polygons    forums.oracle.com

46. Need help with Arrays    forums.oracle.com

Hey everyone , hope you are great and do lots of programming , i am writting a program and need you 2 help me , the programs prompts the user 2 enter (first-name last-name) for three persons and eventually display the name of the person who has the longest first name , give me a hint and i will be the ...

47. Question in making an AnyType array    forums.oracle.com

The easiest solution is to simply ".clone()" the array. That way you don't even need to do the copying of the elements yourself. Alternatively you can simply call [Arrays.copyOf()|http://java.sun.com/javase/6/docs/api/java/util/Arrays.html#copyOf(T%5B%5D,%20int)] which does effectively the same thing as clone(), but allows creating a copy of a different size. Alternatively you can get the component type of the array and create a new array ...

48. bidimensional array    forums.oracle.com

49. add to array    forums.oracle.com

An array has a fixed size. This means when the array is initialized you are unable to add any more elements to the array. Solutions: 1. Create a new array with a larger size and copy the old array to the new array. 2. Use a different data structure, forgot arrays and use an ArrayList which will automatically increase in size. ...

50. not performing an array check properly...    forums.oracle.com

51. Assorting an array?    forums.oracle.com

52. need help with arrays    forums.oracle.com

Are you sure that sorting is what you want? If I enter values of 42, 12, 18, 33, 4 and search for 42. I will expect it to say 42 is the first number but your program will say it is the last number. If this is homework then I would seek clarification from your teacher.

55. Swapping in an array    forums.oracle.com

theo_k wrote: I need to traverse an array of 26 elements and swap two elements, in this case it's a character array. It needs to cover every possible combination of swapping, for example: first traversal will swap elements with a range of 1. S[0] and S[1] will swap positions, then S[1] and S[2]...S[24] and S[25]. Then it will traverse swapping with ...

56. Array Help    forums.oracle.com

57. about array    forums.oracle.com

58. Array assignment - could use some help =|    forums.oracle.com

In the second-last todo, we have to remove the last element from the array (so the 7th element if its got 7 elements...) I don't get how to do that, and then for the last 'todo' part we need to transfer elements from one array to the other: Like this line within the PurseTester class calls the method: harrysPurse.transfer(marysPurse) ; The ...

59. I need help with 2 arrays    forums.oracle.com

Thank you Melanie I was looking at both the areas you mentioned and it didn't seem right to me either, hence the reason I came to these forums =). Anyhow, I tried to do as you said, but there was still too many problems that kept cropping up afterwards, besides my lack of knowledge, working with a GUI made the program ...

60. need some help with this one thanks arrays    forums.oracle.com

i have been trying to figure this out for awhile i am new to programming so any help will be apprecitated Write a for loop that prints, in a column, the lengths of the strings in the array, starting with the length of the last entry in the array, and ending with the array element at position 0. For example, if ...

62. help with arrays    forums.oracle.com

63. Subsequence of the array    forums.oracle.com

64. ARRAYS pass-by-reference    forums.oracle.com

65. for each for bidimensional array...    forums.oracle.com

Sorry =P No, I did not ... But I'll do it right now =) And about the curly braces I didn't wrote them because I'm trainning for the java certification test and in the book says that the test is not that beauty enough to ident and use curly braces all the time... so I'm getting use to it =P but ...

66. Making a new array that calls a method.    forums.oracle.com

By the way depending upon your requirements, the invert method may not be doing what you want. Currently it will invert your array referenced by w1 and return another reference to the same array to w1i. That is both of your variables hold a reference to the same array. If you wished to keep two arrays, w1 = the original array ...

67. Java Array -basic    forums.oracle.com

First: you're wrapping too many Streams: wrap a FileReader in a BufferedReader and you're done. At the end just close the BufferedReader, it will close the wrapped FileReader for you. When you split() a String the result will be an array: array[0] contains the line before the # character and array[1] contains the part following the # character. You don't build ...

68. Simple question on arrays    forums.oracle.com

69. Counting the reoccurance in an array    forums.oracle.com

Think about how your for loop works. On first iteration i = 0. If the random number equals 0 then it will increment 0 by 1 resulting in 1 in count[0]. Count[0] can no longer be incremented because i is now 1. It then checks to see if the second random number is (random100[1]) equal to 1 if it does then ...

70. arrays in JAVA    forums.oracle.com

After some further thought, I think I understand why this isn't allowed. Allowing an ArrayInitializer in a straight assignment is really equivalent to allowing an ArrayInitializer in expressions. In an expression, the type of the ArrayInitializer could be difficult or impossible to infer in some situations. On the other hand, the type is readily apparent in a VariableInitializer since it's only ...

71. Creating array of buttons    forums.oracle.com

72. "count" in Arrays?    forums.oracle.com

73. Array Distribution    forums.oracle.com

2. Depending on your specific requirements, you may not even need to do this calculation. You may not care how many items go into each list. Are you supposed to just come up with the answer as to how many items will go into each list? Or are you supposed to actually distribute them.

74. learning arrays in java    forums.oracle.com

75. Create array    forums.oracle.com

And if I have one class with all the information, name, surname, adress, birthday, mothername, fathername.... and I only want to use name and surname in the array? I have to create another class with only this information. I could write new Person(name,surname,null,null,null.....) but I don't send null, because I have to send only this infromation, because I use this array ...

76. Writing "OR" choices in array form?    forums.oracle.com

77. Help with Array Assignment    forums.oracle.com

The idea is to go through the array and check to see if a '.' is present. A random number between 0-3 is generated and if the array index has a '.' in there, replace it with a letter. If zero is the random number, you check north first, then south, then east, then west. Different directions are testing depending on ...

78. need some help with arrays    forums.oracle.com

Thanks -- I guess the book was confusing a bit. But, I'd like to ask what to do if the length of the array needs to be practically infinite -- say, for example, if one were putting together an address book or a database program program, and needed to store numerous -- mabye hundreds of thousands of records. Would one just ...

79. Problems with Adding two Arrays    forums.oracle.com

81. Creating new Larger arrays    forums.oracle.com

Hi, When you create an array of primitive numbers it is initialized with zeros, so you can't avoid that. You can have a variable that store the quantity of values read so far and later you can only retrieve those values. Using an array is efficient in terms of access time, but it's not so good for memory consumption if you ...

82. very new to java, issue with arrays    forums.oracle.com

83. Arrays help    forums.oracle.com

84. Where do array Methods Come From?    forums.oracle.com

That link explains some of it. So was I correct when I said there's a "hidden" (inaccessible and not listed in the API) class that extends Object and encapsulates the array data? Why go through the trouble of having special syntax for an array if there's a class that could have been used just like any other class?

85. Array exercise. Need help!!!    forums.oracle.com

I got trouble in array exercise. It ask me to print out ten random integer numbers from 0-->9, then write a method to ascend them in order. I can print out ten of them, but don't know how to ascend them in order. May you give me some suggestions to ascend numbers in order. Any replies are appreciated.

86. Question about Arrays.    forums.oracle.com

I'm still a beginner in Java so this question will probably seem simple to most of you. I have constructed a two dimensional array called random_array. I have also made a simple loop to display it. What i want to do next is highlight (by putting a simple symbol next to it for example) a number in the array, but leave ...

87. How to dynamicly enlarge the array    forums.oracle.com

88. Arrays    forums.oracle.com

89. Dice Stimulation using an array    forums.oracle.com

91. Really Basic Array Help Please    forums.oracle.com

Your problem is that you've defined two different things with the name myArray. First you defined a private field named myArray of type String[] (that one is ok, it's probably what you wanted). Then you defined a local variable named myArray of type String[] in the constructor of test and assigned that some value. This means that you constructor never assigns ...

92. the case for raw arrays?    forums.oracle.com

My understanding is Java's designers prefered extensiblity, ease of support, and faster app development, and that performance was given less emphasis. I know the subject of Java perfomance is the subject of heated debate, so I am not asking about that. Rather, What did the designers of Java have in mind with regard to raw arrays? An ArrayList is everything a ...

93. arrays in java    forums.oracle.com

94. array    forums.oracle.com

Is there a way that I could use a repetition structure to find out the occurrence of each number in range. Say, if I enter the number 1 fifteen times, that falls in the range of 0-5. I would like to have an astrisks to display next to that range fifteen times since I entered the number 1 that many times. ...

95. Array to []    forums.oracle.com

96. Help With Homework Reading user input into an Array    forums.oracle.com

According to standard Java coding conventions, class names should start with a capital letter (so, your "answers" should be "Answers"). And, variable and method names should start with a lowercase letter (so, your "Questions" should be "questions"). Also, your variable name should not be the same (case-sensitive match) as your class name. Although it will compile if done syntactically correctly, it ...

97. arrays finding the last entered item?    forums.oracle.com

I'm somewhat new to arrays. Can anyone tell me if there is a method (such as the .length method) for determining the element with the last thing in it. For example, say a Book[] array contains 100 elements but there are only 10 books in the array at element indeces 0-9. Is there a method that will tell me the next ...

98. Extracting only part of an array    forums.oracle.com

Hi, let's say I have an array which size is n. I want to pass part of it (array[x]...array[y]) as a stand alone array to a function. Do I have to create a new array with the size I need (y - x + 1) and for through the old array from x to y and copy, or is there a ...

99. is it possible to grow an array?    forums.oracle.com

100. Please help me on arrays!!!    forums.oracle.com

AuburnPrincess08 wrote: My program compiles and somewhat runs but the information its supposed to present is not coming up like it should. I can not get the scanner on my driver program to scan the information in the correct way. A description of the way the project is supposed to be can be found on this website (http://eng.auburn.edu/~cross/comp1210/lab/projects/Project7A.pdf)..Please help..I would really ...

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.