1. Array Help forums.oracle.com |
|
|
|
We are talking about arrays in class, and I had made a comment about an array symbol means a list will follow, but then I thought about the main method. I was just wondering if anyone had a quick and simple explanation as to why the main method always includes this symbol? Thanks. |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Joseph_Ryan_P2.java //Big Integer Program //Description: // Design and implement a BigInteger class that can add and subtract integers with up to 25 digits. Your // class should also include methods for input and output of the numbers. // // Must Use Arrays ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// import java.io.*; //neccessary imported libraries import java.util.*; public class Joseph_Ryan_P2 { public static void main(String[] args) //the ... |
|
|
|
|
Ive managed to create an array from 3 files consisting of lists of strings. There are matching strings in each file. As i have now put all the strings from every file into an array i wish to find the duplicate data and output it. How would i go about doing this, ne ideas? Many thanks! |
T.J.B.P. wrote: nothing still.... really confused. Read over the tutorials and they dont help with it. So, you don't know how to increment a variable? You don't know how to put something into a particular index in an array? What exactly are you confused about? Create a brand new tiny program with an empty main method. Get it to compile. Then ... |
|
|
im trying to append 2 arrays into 1 but i cant get it right! this is what i tried to do but im getting an error "'class' or 'interface' expected on line 14" plz help!!! import java.util.*; public class appendarrays { public static void main(String[] args) { int[] a = {1, 4, 9, 16, 9}; int[] b = {11, 11, 7, ... |
|
Is it possible to sort array's containing more than half a million records? I'm currently getting OutOfMemoryError. Will it work better if I use TreeMaps or is it simply impossible to sort huge arrays in Java? I've got a big array containing lots of stock exchange data. The data needs to be sorted. I can't put it in a DB because ... |
|
|
19. array forums.oracle.com |
What do you mean "where at"? You currently have two loops in your code, one after the other. You will need to have one nested inside the other, unless you have come up with some other algorithm that I don't know about. As it stands your code is nowhere near achieving what you want. Try getting a piece of paper and ... |
|
|
Hi folks I been doing some coding wth java (JDK) and I found this method inconvienient for an array of length 6: static void check(int z1,int z2,int z3,int z4,int z5,int z6,int pt1,int pt2,int size){ boolean verify = ((pt2 <= z2 + 20) && (pt2 >= z2 - 20) && (pt1 <= z1 + 20) && (pt1 >= z1 - 20)) || ... |
|
|
|
Design and implement an application that reads a number of integers that are in the range 0 to 50 inclusive and counts how many occurrences of each are entered. After all input has been processed, print all of the values (with the number of occurrences) that were entered one or more times. |
28. Arrays forums.oracle.com[quote]it is hard for me to help when I dont have full grasp on the thing.(not able to comment on snippets yet) I think more advance experience is needed here.[quote] The getLastName method is just a method that returns lastname. It's in another class. Same with the other methods I get. The last name string part of the array is what ... |
Using an array, count the number of occurrences of each letter (regardless of whether it is upper or lower case (so for example, an 'A' and an 'a' both count for the first letter of the alphabet). In a separate counter, also count the total number of "other" characters ('.', '?', ' ', '2', etc.). The final exclamation point does not ... |
30. arrays forums.oracle.comYour A1 class has only one constructor, which you defined. That constructor takes an argument, so it is not a "default constructor". A "default constructor" is a constructor which takes no arguments, also known as a "no-argument constructor". That has nothing to do with the behavior of setting members to default values if you don't explicitly set them. If you do ... |
OK, you made the changes like I suggested but you still haven't done the sorting. We are not going to do it for you. Once again you need to search for a sorting algorithm and implement it. Once you have done that and if it doesn't work, come back and ask for help. |
|
I'd suggest: 1) determine which row and column the user clicked on. 2) figure out whether the empty square is in the row, or the column. If neither, report an error. 3) Then swap all the values in the row/column, from the empty spot to the spot the user clicked on, one step at a time, until the spot the user ... |
Write a Java application for a company payroll that has three different types of employees: secretary, junior salesman and senior salesman. * Design an employee superclass that contains an instance variable for the employee name. In addition, there should be an (abstract) method to compute the yearly bonus that employees receive in the month of December. * Design subclasses for each ... |
Hey all first post and a stupid one im afraid. Meant to be working through a series of problems based on arrays and i have none of my past work to help me, long story short, it was erased. Anyway im new to java and so far terrible as my college really hiked up the difficulty and unfortunately left me behind. ... |
It will be like this User put in numbers 1 34 56 78 Sytem print out the numbers 1 34 56 78 system tells you that; thelargest number is 78 and in array index 3 here is where my problem begin!! System ask uster to put in a number interval example 10-35 All the numbers in this interval will be 0 ... |
My instructor wants us to use a for loop. I am not sure why. I think that is why I am having a hard time compiling this, because I am not sure I understand why she wants us to use a for loop. I do not know how to add my products. I am not sure If I use DVD.getProductname or ... |
|
|
|
|
|
|
Add all components manually (via drag and drop). Then create an array in code and fill it with all the component variables. Trouble is, this does not help with coding the event handling of the controls. With VB a single event handler is coded for the array and it is passed the index of the control. I guess I must accept ... |
Since Java is an object oriented language you might want to create a Player class. Then think about how you can break things down and decide where certain methods go, in the Player class or the game class. As for determing the Player with the greatest wins, create another temp variable to hold the player with the most correct so far. ... |
I am trying to assign an array that contains information from an imported txt file. Here is the description: Description Here is a sample interaction between a user and the program you will write in the Lab7 class (user inputs are in bold): Enter input file name: info.txt Name Score1 Score2 Score3 Total Andy Borders 200 250 400 850 + John ... |
|
|
49. re:array forums.oracle.com |
50. Arrays forums.oracle.comHow would I go about fixing that? I tried putting Employee in front of it instead of int but it creates more problems. Can someone move this to the Swing forum? I just saw a post on my last thread saying it would be better to put it there. Edited by: Program_1 on Nov 15, 2007 9:19 PM |
|
52. Arrays forums.oracle.com |
|
|
lol. nope it doesn't change, but I need it to, as i'm sure you're aware. I really can't think what I need to do! do I need a nested loop inside my for loop, in order to make X change? sorry if I'm being thick, I just can't figure it out, even though it is obviously very easy. |
Actually, it only prints out zero nine-tenths of the time. Look at what you're doing. You're selecting a single random bin, and then putting all items in that single bin. You probably want to select a new random bin for each item (i.e. do it in the loop). Other problems: 1) You're importing java.util.Random, but not using it. You're using Math.random, ... |
Rather than "trying things", read reply 5 and do what it says to see for yourself what the problem is. You read these double values, but you don't add them to the array until the next time around the loop. In the case of the last value you enter that "next time" never happens. |
|
|
|
The title says it all. I need to know what other properties does an array has. For instance, we can use "x_array.length" to find out no.of elements in x_array. Is there a property to tell how many dimension does the array has ? The ".length" only gives size of one dimension. To find the size of another dimension, I need to ... |
|
/** RainFall class will store the total rainfall for each of the 12 months into doubles. In addition there will be methods that return the toal rainfall for the year, the average monthly rainfall, month with the most rain/ least rain. */ public class RainFall { private double[] rain; // The rain data /** The constructor copies the elements in an ... |
int sum = 0; for (int i = 0; i < chromosomeLength.length; i++) sum += chromosomeLength; System.out.println(sum); System.out.println(chromosomeLength[0]); System.out.println(chromosomeLength[1]); System.out.println(chromosomeLength[499]); } } obviously in java, an array of 500 elements goes from 0 - 499 in terms of memory locations. I would like the 0th element to hold a value of 1, the 1th element to hold a value of 2, ... |
65. arrays forums.oracle.com |
hey guys, just had a quick question, i wanted to write a program that reads a sequence of integers into an array and have it compute the alternating sum of all the elements in the array. how would i get started in doing this... is there an easy method to figuring out how to do this??? |
i have an array called bookitems[](which contains objects) in a method called offers(). i would like to access this method from another method and add a new object to the already existing bookitems[] how to do this? Iam thinking about using arraylist in the later method and trying to convert bookitems[] into arraylist .so that i can use add method to ... |
68. arrays forums.oracle.com |
|
Here is the problem I got: I created a book class with various methods. On top of that I created another class called Library. Library class constructor is supposed to have a field saying how many books are in the "library". You enter a number, and it should generate an array with the specified number of slots (that will contain books). ... |
Here is the problem I got: I created a book class with various methods. On top of that I created another class called Library. Library class constructor is supposed to have a field saying how many books are in the "library". You enter a number, and it should generate an array with the specified number of slots (that will contain books). ... |
|
73. Array Lab forums.oracle.comI'm having trouble with this lab on Arrays: In the following code fragment, a is a five-element array of Strings and p is a five-element array of ints. Write code that assigns to each element of p the length of the corresponding element of a. For example, when a is the array with elements "Oops", "I", "did", "it", "again" (in that ... |
I have values in an Array, now I want to remove those values that are twice in the array. For example year [] = 2,2,2,4,5,6,7,7'; Now I want to check the array to see if how many numbers there are in it, that are redudant, such as 2 and 7. And if there are redudant numbers then I want to smoke ... |
|
76. Arrays... forums.oracle.comHi there, I'm having a bit of trouble when it comes to arrays of certain class types. I remember that there was a way to print them, but I've forgotten how and now I can't really find the info out there. Basically, I want to print out an array of the type "Persons" which I receive from another class, but running ... |
Also, this is not very good programming practice. You would want all of your array items to be objects of the same class except in very unusual circumstances. What makes you to want to create such a chimeric array? Also, as I mentioned previously in another post, please don't give newbies full code solutions to their questions. It inhibits learning. |
Thank you for the quick response. What I would like this code to do is to display the three loan details on the window console. I receive the first loan details but the second and third loans have a rate of 0.00%. I am not a programmer as you can see. I just would like to know what needs to be ... |
79. Array forums.oracle.com |
80. sub arrays forums.oracle.com |
81. arrays forums.oracle.com |
No, not multidimensional arrays. What I'm trying to do is get 5 arrays, each would contain 1/5th of the first array, so if the first array had 100 elements, the second would have the first 20, the third would have 20-40 etc etc until the 6th would have 80-100. For example, I have 5 arrays named Arr1 to Arr5, and a ... |
|
Thank you... out of all the replies yours was the most useful...I am a little further ahead now because I know what not to do. What I posted was not my program... I am still thinking over ways to start the project... What I posted was "would this work" kind of code. What should I be doing to create and use ... |
85. Array forums.oracle.comAn array is composed of elements that hold values. Methods return values. So I'm assuming you need a method to return true if the array contains no 1's and no 3's. -- Write a method that returns boolean and takes a parameter of an array of ints (or whatever number type you use). -- Declare a local boolean variable and initialize ... |
If I understand your problem correctly, you want to be able to add more items in your dvd collection array yet your array is limited in size. If that is the case, try using an ArrayList. This will allow you to add and remove as needed and won't require you to specify a array size. If I have misunderstood your question, ... |
Hey guys, quick question i keep getting a compiler error that i ahve not initalized my array. I know what that means, but don't know how to fix it from giving me that error. here is the string i constructed. String[] data1; IT says i have to uinitalize that how can i do this? I tried.. String[] data1""; But that doesn't ... |
I have a data file setup like this: 111 123 112 321 124 999 I'm reading in each the three integers per line into three different variables. I then want to store those variables into a 3D array. Could someone provide an example of a program that pulls data like this from an external file and populates a 3d array with ... |
89. ARRAY HELP forums.oracle.comIt depends on what "removes" means. One interpretation would be: if the array holds 7 ints (1 2 3 4 5 6 7) and the element at pos 2 is removed then your array could be (1 2 4 5 6 7). That is all other elements are moved forward in the array. |
90. ARRAY HELP forums.oracle.com |
I create an array "sales[]" of type Object.And the array is used to hold 5 objects of type "Item" class.Item class having a constructor which sets the values for fields of itemname of type String,Itemcost of type double,Itemid of type String aslike........ Itemid Itemname Itemcost sales[0]---> id1 xxxxxx 1.90 sales[1]--->id2 yyyyyy 2.90 . . . .sales[4]---> .................................................. I am using a ... |
|
/*An applet to input 5 numbers, each of which is between 10 and 100 inclusive. As each number is read, display it only if it is not a duplicate of a number already read. Use the smallest possible array. Display results in a JTextArea. Use setText to update the results after each value is input by the user. */ |
94. 2 D Array forums.oracle.com |
|
96. 2 D Array forums.oracle.comOn the other hand, you pass an int to find(long searchKey) int searchKey = 23; if( arr.find(searchKey) Decide whether you want a long [ ] [ ] array or a int [ ] [ ] array and make the whole program consistent. And in the delete method, you need a nested loop to iterate through all remaining elements. And thar won't ... |
97. array help forums.oracle.com |
How many goddam times does it need to be said? Include your error messages. However in this case it is obvious. When you pass your parameters that is all you do. You don't have to inlcude their types again. Also, the method is expecting an array but you are passing a single element of the array. Ooops. Totally missed that the ... |
99. arrays forums.oracle.com |
Ha! Ha! Ok guys, thanks for the advice so far, I guess I can see where I am causing some confusion here. cotton.m - I get the basics of arrays & how to create them, my code is perhaps a little misleading above. Your example shows static elements that the user already knows and can assign to each element correct? We'll ... |