1. Array forums.oracle.com |
|
|
|
I'm using POI-HSSF to create EXCEL workbooks. Does anyone know whether one can create an array of sheets within a workbook? At least, I think that would be the best way to do it. I'd like to be able to set a variable at the beginning of a program representing the number of sheets to be created (eventually I want this ... |
6. arrays forums.oracle.comThis is a very simple question, but I have not been able to figure it out. any help is greatly appreciated. This is regarding class and object methods. Code(1) using class method works fine. cODE(1) public class arr{ public static int[] values={1,2,4,10}; static double av(int[] values) { double sum=0.0; for (int i=0; i |
|
|
8. arrays forums.oracle.com |
|
No, I don't think it is. children = new String[5]; is a statement, and that can't be at the top level in a class. It must be in a method, constructor, or initializer block. I assume this is what the instructor was talking about. You can, however, do String[] children = new String[5]; at the top level in a class. That's ... |
I need to build an array with 3 columns the first being int, the second string and the third double. This is to create a text file with 3 columns of different data. I'm assuming this is what is called the multi-dimensional array. I know about the int array[] = {100, 200, 300, 700"}; String array[] = {"A, B, C, D"}; ... |
|
|
|
/*Design and implement an application that reads an arbitrary 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.*/ |
|
|
Example, if i have this string array: int count=0; for (int i = 0; i < n; i++) { String [] alpha={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}; System.out.println(count" " + alpha[ i] ); count++; } eventually the loop reach to array [25] it will stop because array will out of bound if it go above 26. the question is how can i make the array go ... |
|
Can anyone explain why the constructor doesn't get called when I create an array of objects of class Ex4. I've learnt from books that in Java the constructor gets called whenever memory is allocated for an object using new. public class Ex4 { Ex4() { System.out.println("Called Ex4 Constructor!!!"); } public static void main(String[] args) { Ex4[] arr = new Ex4[5]; } ... |
Ok, this is about as basic as I can get and still understand what I am doing. ............... I have started back at the very basics, where should I go from here? It's not enough to just start at the basics, you have to continue on. We can correct your mistakes here, but we can't teach you Java. You must teach ... |
import java.io.*; import java.util.*; import java.text.*; public class ZinniSpeech { private static String[] originalZinni; private static Scanner rawText; private static StringBuilder rawTextString; private static StringTokenizer rawTextToken; private static int wordTotal1; private static int wordTotalFinal; public static void main(String args[])throws IOException { rawText = new Scanner(new File( "\\Java\\Zinni ZinniSpeechCDI5_04.txt")); rawText.useDelimiter(" W+"); rawTextString = new StringBuilder(); while(rawText.hasNext()) { rawTextString.append(" " + rawText.next()); } ... |
Hi, is it possible to overwrite a whole array java ? It seems I can only replace each cell individually, ie: myaray[3][4] = 32, or replace it with another array ie: myarray = newarray.... In javascript I was able to just say myarray[3] = [newdata,newdata,newdata] ... but I don't seem to be able to do that in java ? making multiple ... |
I need to write a method that adds intergers to an array and keeps it in sorted order I have written the following code: public void add(int value) { int index = binarySearch(elementData,value,0, size -1); for (int i = size; i > index; i- -) { elementData = elementData[i - 1]; elementData[index + 1] = value; size++; } } I keep ... |
Usually when you get errors, you post them here so we don't have to read your mind. I can see two errors. You cannot have any code after a return statement. The return means go back to where this method was called from immediately. If it does that, how is it supposed to execute any lines after the return? Also the ... |
I may not have worded it very well. The array has 16 elements. The middle element is 8. If you partition this array and the pivot ends up at 9, then you need to partition again from 0 to 9 (the partition that contains the 8), not 10 to 16. If the pivot ends up at 2, you need to partition ... |
I need a class to have a member which is an array .This array should have a constant size irrespective of the instances that are created on this class. Java prevents declaring size of an array.But the above scenario cannot be reached.I need to know why Java has prevented constant size declaration.Please post your opinions on this issue |
I have a question with arrays. I have a simple inventory program that I am writing(very simple). I have declared and created my array. Is this the time I should build a new class outside of my main in order to hold my array? I am still trying to sort through classes and when to create them. My thought is that ... |
I am designing a program that factors several numbers. I would like to have the "factoring" method as a subroutine of a main method with all the I/O stuff, to keep things organized. I was wondering what the syntax is for a method that returns an array (which would hold the factors). Would it be like this: "Array[][] returnfactors()" if the ... |
Hello All, I just ran into something I hadn't seen before, I have a String[] that is: String[] someArr = getSomeValuesMethod(); If the getSomeValuesMethod() returns null, then how do I populate the array with a pre-determined value, like a message? The only thing I could get to work was to create an if block condition that if the array was null, ... |
another question is if u have an array and the user wishes to delete one element, i kno u can have a second array with 1 less element than the original and transfer the other elements over that are to be kept. but the only way i know how to do this is with a loop and the loop i am ... |
When i run it i am getting: 3 Doors Down Away From The Sun. Made in: 2002. Rank: 5 1 - Kryptonite 2 - Loser 3 - Duck And Run 4 - Not Enough 5 - Be Like That 6 - Life Of My Own 7 - Better Life 8 - Down Poison 9 - By My Side 10 - Smack ... |
|
|
Panel row2 = new Panel(); Label numbersLabel = new Label("Your picks: ", Label.RIGHT); TextField[] numbers = new TextField[6]; Label winnerLabel = new Label("Winners: ", Label.RIGHT); TextField[] winners = new TextField[7]; //array for 6 textfields to declare winning numbers, 1 for slowdown TextField slowDown = winners[6]; Panel row3 = new Panel(); Button stop = new Button("Stop"); Button play = new Button("Play"); Button ... |
Still no problem. You just have to figure out the right steps, and it's still easily solved. 1) Create a temp int array, same size as input 2) then iterate through your input array. 3) If the current int has no duplicates add it to the temp int array, but keep a count of how many have been added and use ... |
37. arrays forums.oracle.comHi All i have an array of 'client' obejects (a client has methods for the name, salary and taxation). in the UI class that contains the main method is where the client array is declared and initialised but we cant instantiate it with x amount of elements as an element can only be instantiated as needed. if i create a method ... |
|
Hi, I guess that this is not the solution. What I have to do is to create an array, lets say an array of int, then, I have to put all the array in a second array, but each position in the second array have an array of the first type. Each position of the second array have arrays as values. ... |
Hi everybody. how can I fill a bidimensional array with different values in its positions? For a single array I use something like: array[position] = 5; but if a have a bidimensional, I should think that is something like: array[position][position] = 5,10; but this line do not compile. How can I do it? Kind regards. |
|
Yep, if I change a value in the second array it is reflected in the first. I figured it had to do with them being just pointers. Thanks for the help. I guess one more question to add to this would be is there any way to set them equal with a one line command, or is the only way a ... |
|
So you have 32 cache blocks, and one boolean in the array for each one. If you want to check whether block 27 is valid, then examine the 27th boolean value in the validity array, and return that. Your method for determining if a cache block is empty takes an int parameter, and returns a boolean that describes if that cache ... |
|
46. array forums.oracle.comYour loop should execute some large number of times, say 5000. The large number of times being akin to giving the array a vigorous shaking. You can do better as someone posted a while back: (1) Start with the last array element, ie at index array.length-1, and swap it with the element at some random position 0->array.length-1 (inclusive) (2) Reduce the ... |
hi, i need to create new array consisting of the elements at postion 2 in the test array e.g i have an the split array String[] test = line.split (which will split the lines, which have words separated by spaces, into arrays and i want to create another array e.g. String[] test2 = test[1] which should create another array that contains ... |
Ok my bad but this has been really frustrating me. The hull pointed exception is getting thrown inside the loadFromFile method at the very end, so when i return it its printing out "reading player data" then reading all 44 players in, but the throwing a nullpointerexception before be before it prints out "players loaded" Message was edited by: UFC1 Message ... |
49. Arrays forums.oracle.comCould you be a little more specific about where I should put the while loop at? Should I substitute it in at all of my while loops or what? To be honest, your code is very hard to follow. You seem to have a lot of variables you don't need and most of them don't have meaningful names. Try cleaning up ... |
Now I'm working on the past paper to get ready for the exam. I get stuck on this question - "Explain how it is possible using class hierarchies to create an array of seemingly different objects in Java. Illustrate your answer with an example." I don't quite understand the question.. I think it asks me to build an array that can ... |
|
I'm doing a prog for uni and have a prob with my code. I'm trying to make an array from a txt file. Though when i try to save the players to the array its just saving the same string over and over. Can anyone see why this is happening. Thanks for any help. public class Player1 { private String name; ... |
|
I have a problem that i'm struggling to solve. i've got to write a program to determine the day of the week most children were born out of a group of 20 children. The number of the day of the week on which a child was born will be entered by the user. i have set the array up and the ... |
I have an array storing numbers. I have a combo box with choices in it, when a choice is made a number from the array is displayed in a text field. I want to add the numbers together that have been selected. I created a variable called total and used the code. total = code + code; i get the error, ... |
|
|
|
|
Don't flag your questions as urgent. It's rude. Also don't think that waving with a couple of worthless Dukes is going to get you better/quicker help. The reason I respond to your question is because you have explained your problem well and used code tags. you know, I had the same thought come to me, so I just barely posted the ... |
61. array forums.oracle.com/**(This method attempts to put a marker in the square at column i, row j. Both i and j can take values of 0, 1 and 2, to access the 3x3=9 squares. Player 1?s markers are the character ?x?; Player 2?s markers are the character ?o?. If i & j are valid and that square is free, the current player?s marker ... |
62. Array forums.oracle.comi undertsnd the difference between student and an array of student...... my problem is tha t i don t know how to get all the students with the highest mark . another problem is with the method getMeanMark() i don t know why but doesn t give the average of the marks but just gives to me the latest can you ... |
Hi, My question is i have 3 arrays 1 of string type and 2 of double type. basically one is a product and the other two are the code for the product and the price for the product. I want to display the price and code from the arrays in a textfield when the product is selected from a jcombobox. How ... |
I was tasked with creating a hangman game. Is it possible to compare arrays? IE: The first array has the word "music" in it , the second has "_ _ _ _ " The user enters a "u". The program looks at the first array and confirms there is an "u" and replaces it in the second array giving us " ... |
public static void main(String[] args) { int [] scores = new int[SIZE]; int count = 0; double average = 0.0; count = loadArray(scores); average = determineAverage(scores, count); displayResults(scores, count, average); System.exit(0); } private static int loadArray(int[]n) { int count = 0; int score = Integer.parseInt(JOptionPane.showInputDialog("Input text press Enter(-1 to end)")); while(count < SIZE&& score != -1){ n[count] = score; count++; score ... |
/** * @param args the command line arguments */ public static void main(String[] args) { Random RandomDie1 = new Random(); int frequency[] = new int[13]; Random RandomDie2 = new Random(); int frequency1[] = new int[13]; for ( int Die1 = 1; Die1 <= 36000; Die1++) ++frequency[ 1 + RandomDie1.nextInt(6)]; for( int Die2 = 1; Die2 <= 36000; Die2++) ++frequency1[ 1 + ... |
67. Array help forums.oracle.comThis is from the Format class (you might like to read it to get a better idea). The % means get the corresponding argument in the list of arguments at the end (the result of the call to detemineOutstanding). So you can have 1 or more agruments spearated by commas. the 11 means print the argument in a space 11 chars ... |
|
69. Arrays forums.oracle.comTo begin with, if you can use either swing, or std in / std out, I would use std in / std out. There's a LOT less work using those. Start with figuring out how to write "Enter the size of the array (1-10)" to the console, and then, how to read the integer response from the console. Once you've figured ... |
Hi, I am trying to create a 2-Dimensional char array, in which it has a row and column index. The user will input the size for both the row and col, and then input the values for the elements in each index. After this the program will then print out the input value in a row by col matrix. So far ... |
Hi, I am trying to make a class that contains a method that receives a char array, and then tries to switch the first index with the last index, then the second with the second to last, and so on until all indexes have been switched. However, I have hit a snag where the code only does half the job (it ... |
|
73. Array help forums.oracle.comto find out the average of something i believe i need to add something like this for (i = 0; i < Grade.length; i++) //Loop for each element in the array { total = total + Grade; //Print the Grade array index and value ta.append("\t" + i + "\t" + Grade + "\t" + supermarket + "\t" + "\n"); |
74. array forums.oracle.com |
75. Array forums.oracle.com |
|
import java.util.Scanner; public class Quiz { Question[] array = new Question[25]; public void addQuestion(String qTemp) { Scanner scan = new Scanner(System.in); System.out.println ("Type the question you want to add followed by comma and the answer"); for (int i = 0; i < array.length; i++) { qTemp = scan.nextLine(); } for (int x = 0 ; x < array.length ; x++) qTemp.add(array[x]); ... |
Are you allowed to create a Student class that holds all the data, ie name and grades? If so you could write a method that calculates the average for a single student. Then all you need is to iterate over all students, sum their averages and then calculate the final average. If not, when you calculate the average for current student, ... |
|
|
reservation class for adding passengers. [codepublic class Reservation { private String seatClass; private int numPassengers; // First class has 8 seats (2 rows of 4 seats each) String[] firstClassSeat = new String[8]; // Economy class has 24 seats (4 rows of 6 seats each) String[] economyClassSeat = new String[18]; // Temp array for first class String[] tempArrayF = new String[8]; // ... |
I have to write a method that will accept an array as a parameter and return the same array, but with twice as many elements in it. I wrote the method but when calling it in the main method I have: Arraypro stuff = new Arrayprof(); int array[] = stuff.exArray(int[] temp); where exArray(...) is the name of the method. The error ... |
|
/* * The argument variable is now assigned a reference to a completely * new array. When this function returns the variable the caller used to * invoke this method will have exactly the same value it did before this * method was invoked. Ie it will *still* refer to an array of nulls. */ |
this is the program Make a class name TestStuff, which has a single instance variable that is an array of test scores (you can assume they are whole numbers only). The class will have the following methods: TestStuff(): This is a constructor that will initialize the array to have 10 elements. Give each element the value of whatever index it is ... |
First, don't store data in parallel arrays like that. Create a class that encapsulates all the corresponding, and store instances of that class in a java.util.List or array (or a java.util.Set if you don't really need an ordering). I suppose you could use Scanner.nextLine after you get the third int on a line. That should get you past the newline and ... |
I would like some help with a question on arrays I am supposed to find the mean and the mode of a 2 D array I created a nested for loop the totaled the array = that to int total and then I set int average = total / array.length, and it is not correctly averaging the array, my professor said ... |
88. Arrays forums.oracle.com |
|
|
|
|
no one is confused except questie. my program will calculate the exact length of an array. Fastmike, you have some nerve to criticise other people. You completely missed the point of my post. The point is that this whole thread is retarded. The "count" of an array is just array.length. You dont need to write a method to return the length, ... |
No. Array indeces start from 0. So if You have array of size 6 the fields are: [0] [1] [2] [3] [4] [5] element index 1 2 3 4 5 6 element and array.length returns (in this example) 6 Outer for the loop will then be 5 and that is last element's index in an array. If You use array.length-1 (5->outer=4) ... |
|
Your problem here is scope. You are probably declaring the array inside of a method or block, and then attempting to use that array in that "display" line outside of that method or block. More code is needed to properly suggest a fix. However, if it is only a block, declare "temps" before the block, and then just fill its values ... |
|
|
I'm just working through some of the tutorials and I'm following the one which gives you MapViewers. It appears that you can assign MapMarkers and you can create an array with : markers = new MapMarker[1]; when I set this as in the tutorial via another variable : mapMarker1.setLatitude(52.452); mapMarker1.setLongitude(0.052); markers[0] = mapMarker1; everything works but then changing the value of ... |
Hi everyone, i had a question i created an array with 4 strings, i could add some words into array when the array is not full. but when it is full, i want to remove the oldest entry and put the new entey in, how could i achieve this? thansk a lot |