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

1. how to use array in array?    coderanch.com

class array { public static void main(String[] args) { int a[] = {1, 2, 3}; int b[] = {4, 5, 6}; int c[] = {7, 8, 9}; Object arr[] = new Object[4]; arr[0] = a; arr[1] = b; arr[2] = c; int d[] = (int[]) arr[0]; for ( int i=0;i

2. arrays - varied locations allowed?    coderanch.com

I want to create several arrays to hold different pieces of data. The data will be number related and it would be convenient to make each number in the array be appropriate to the string held there. for instance month[1] = "January" month[2] = "February" *assume I don't need these months* month[10] = "October" month[11] = "November" Can I just omit ...

3. Evaluating the contents of an entire array    coderanch.com

In an IF loop, I want to evaluate the entire contents of a char[] array to see if any of the characters in it match and take action accordingly. I'll post what I have so far. Any help on this would be extremely appreciated, and please note I cannot use regular expressions in this (yes it is an assignment, I'm not ...

4. array being overwritten    coderanch.com

I have a program with three classes the first `Employee class` introduces a hashIndex calculated from empName the second `EmployeeSort` takes the hashIndex and places the employee class instance into an array of which will be eventually be Employee class objects.I have the Last class passing the name and job using the JOptionPane unfortunately each pass overwrites the last entry in ...

5. Displaying a histogram using input from an array    coderanch.com

Hello folks, I am currently working on a problem that inputs 20 numbers into an array and the numbers being in the range of 0 to 100. I had to calculate smallest, largest, mean and average of all the numbers in this array which i was able to do without any problem. But the second half of the problem is to ...

6. Arrays    coderanch.com

If you need to use arrays, you have two choices: 1. Create a class to hold both fields, then add objects of that class to the array; 2. Create two parallel arrays, one for each field. When you save the data or retrieve the data, you use the same index for both arrays. Hope that helps.

7. Help with an array    coderanch.com

Hello, I am working on an array program. I have some array based questions. How can I limit the user input to 80? When I run the program it allows me to enter in as many as I want. Is there a way to know if the user has input symbols instead of letters or numbers? I am going to break ...

8. Array    coderanch.com

Hi, Welcome to JavaRanch! We don't like to do people's work for them, but we do like to help people learn. This is a simple sort of program, with three parts: 1) Collect some input 2) Compute some numbers 3) Print a report Tackle each part separately. So: go get started. Come back to this thread and show us what you ...

9. Array with Buttons"    coderanch.com

import java.awt.*; import java.applet.Applet; import java.awt.event.*; public class Array extends Applet implements ActionListener { private Button throwDice; private boolean thrown = false; public void init() { throwDice = new Button("Price List"); add (throwDice); throwDice.addActionListener(this); throwDice = new Button("UB 40"); add (throwDice); throwDice.addActionListener(this); throwDice = new Button("WD 40"); add (throwDice); throwDice.addActionListener(this); throwDice = new Button("R2D2"); add (throwDice); throwDice.addActionListener(this); throwDice = new Button("C3P0"); ...

10. Array Questions    coderanch.com

Hi all, I was asked by someone to give comments on some java statements. The statements and my comments are as under. I thought well before answering and also verified by making a small program. But I was told that I was wrong. I cant figure out which comment is incorrect. No 1: -------- char string [50]; This is an invalid ...

11. functions contains for array ?    coderanch.com

Is there existing function or easy way to check if the object is included in array, like contains of arraylist? I know for loop can do it, but tired to insert the for loop in so many places. Hope to get some quick method or existing one? or if there is quick way to convert array to arraylist without using the ...

12. empty array[][] contents    coderanch.com

For built-in types, like char, int, float, etc., this is tough. You will have to define what "empty" means. Since you are using a char array, are there specific characters you are using? What is the purpose of the array and what are the valid characters that can be stored in it? You can choose a different character to represent "empty". ...

13. Array    coderanch.com

Dear all, Suppose I have an array whereby Singer has members like title,year,price; am I rite to do it in the following manner? Singer CD[] = new Singer [30]; Singer tmpCD = new Singer(); for(i=0; i<10; i++) { tmpCD.title = 'retrieve info from file'; tmpCD.year = 'retrieve info from file'; tmpCD.price = 'retrieve info from file' CD[i] = tmpCD; } or ...

14. Help with Arrays Please    coderanch.com

15. question related to ragged array    coderanch.com

ganesh -- I don't think Mr. Stoddard is answering the question you asked, so I'll give it a try. Java "2D" arrays aren't really 2D, as you seem to know: a 2D array is a 1D array of column arrays. The number of columns is thus fixed, but the number of "rows" in each column can vary. You're asking, I think, ...

16. retrieving array    coderanch.com

Hi When i run this program it only prints to the screen the last name and course enterd, it all compiles ok, could somebody have a look at the code for me and if possible point out where i have gone wrong. public class Student { // Private members private String name; private String course; // constructor for new student object ...

17. easy array question    coderanch.com

18. Array probm    coderanch.com

19. Array lengths    coderanch.com

Sorry about the lack of info any way here is the error if i set the array size 10. Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10 at arrays.Storage.addStudent(Student.java:69) at arrays.StudentTest.main(StudentTest.java:19) this happens after i have added five new names to the array here is the add method i have: public void addStudent(Student studentObj, int count) { int hash = studentObj.hashCode(numOfStudents); int index ...

20. doubt about array construction    coderanch.com

Marilyn means that Arrays are special cases in java - they work a little differently than other classes. so when you say int[] houses=new int[20]; Java knows you are making an array of ints (or whatever you're making an array of, and knows how to make that array. i THINK it is just grabbing a contiguous block of memory large enough ...

21. Empty Array as opposed to Null Array    coderanch.com

I'm used to using if (thisString != null && thisString.length() > 0) I'm getting back an empty array (from within a serialized object over Sockets), my question is this - how do I check for an empty array? Example... public static void main(String[] args) { String[][] x = new String[0][0]; if ( x == null ) { System.out.println("x is null"); } ...

22. array    coderanch.com

23. Arrays    coderanch.com

24. Array storing    coderanch.com

i want to use an array to store the item from database instead of hard coding the item which is shown at the last part of the code. When i do a System.out.println(itemName + serialNumber+ carModel + listPrice); , it did show the item from database but when i use an array to store it, it does not show the correct ...

25. incrementing arrays    coderanch.com

Hi again. Is it possible to increment an array? I need to determine what amount of 12 has a certain characteristic, with the others not having that characteristic. For instance, consider the following code snippet: int z = 0; if (myMonth [z].Days == 31){ myCount z ; //myCount being declared as a new array for the counter System.out.println("These months have 31 ...

26. Help needed regarding an array    coderanch.com

I'm guessing you're getting a null pointer exception? what i think is happening is that while you declare your array to hold three elements, you have never CREATED those elements. In other words, your array is all set and waiting to hold three Values. when you call UPDATE_VALUES[i].setFieldValue(fvalue); you're saying "call the method setFieldValue() on the object in position i". There ...

27. Having trouble getting started with an array method    coderanch.com

Hello everyone first off let me say that this assignment is for school but I'm not trying to mooch I want to learn. My assignment is to write 8 different methods that do vaious things to arrays. I have done a couple of the methods no problem but on this one I don't even know where to start. The Idea is ...

28. Problems with returning Arrays    coderanch.com

Hi, I'm in a newbie Java class and I'm stuck on a really annoying problem. Ok, here is my code. The code is receiving an array from DataWharehouse class (weight[]) and I have to calculate the elements into kilograms and send them to another class file (HealthRiskCalculatorTester). public class HealthRiskCalculator { public double kilosFromPounds() { DataWharehouse data = new DataWharehouse(); double[] ...

29. Subtract arrays    coderanch.com

hi all i have created 2 int array both have the same size of 15... i don't have to fill it all in ... so it can be half of the array filt in with number and the rest will be zero's by default... so each element can have only one digit example: int[] arr1 = {1,2,3,4,6,8,5} int[] arr2 ={1,0,0,2,3,2} int[] ...

30. array of stacks    coderanch.com

31. Array question    coderanch.com

Hello, My professor wants me to "swap" the values of the first and the last array object and I am having a hard time figuring this out. I don't know if I should create another "for" loop to code this swap or if I can just code one line and make the first value equal the last value. Here is the ...

32. Help needed with ARRAYS, please.    coderanch.com

1st up here's your code indented, use the code tag to preserve this. public BigInteger getUserLimit(User user){ String userid = user.getUserID(); String[] userlimit = user.getNsklmt(); String entity = getRequisitionID().getEntity(); String[] hospcodes = user.getHospcodes(); int i = 0; while (userlimit == null && i < hospcodes.length){ BigInteger nsklmt = new BigInteger("0"); i++; return nsklmt; } while (userlimit != null && i < ...

33. array confusion    coderanch.com

Good nite all, I am somewhat stuck on an assignment problem;which will probably require me seeing the prof again. But, I though maybe I could try to solve as much as I could before seeing him; so it doesn't think I didn't give it my all. Anyways, the problem basically requires input to be read from the console, and each string ...

34. How to create a new array with items that are identical in two other arrays?    coderanch.com

Hi, I have two arrays that contain integers. I want to create a new array with only integers that exist in two other arrays. Is there a simple way to do this? I can either create a new array or erase items from one of the arrays if it does not exist in the other. Thanks!

35. ColorTable Array!!    coderanch.com

ok I'm doing a color table array, it displays 100x20 rectangles(256 of them) with 256 shades of green, blue, or red. My name is printed in the very top left had rect. and the rest are also numbered. im having a problem getting all the numbers to show up... here is my code.... import java.awt.*; import javax.swing.*; import java.awt.event.*; public class ...

36. reassigning arrays    coderanch.com

I have a program that looks something like this, but longer, of course. public class MixPict { int r = 2; int[] order = {0,1,2,3}; } public class TesttheMixPict { public static void main (String [] args) { MixPict m = new MixPict(); m.r = 3; m.order = {1,0,2,3,4,5,6,7,8}; } } The MixPict class compiled OK and the m.r=3 line compiled, ...

37. Array increment    coderanch.com

You've neglected to put braces around the body of this "for" loop: for(int i = 0; i < a2.length; i++) System.out.println (a2.length); a2[i]++; So that the body is actually just the "println" statement, and at the third line, "i" is undefined. If you comment out the "println", then the assignment alone becomes the body of the loop.

38. Need hlp wit array. plz help    coderanch.com

Hi all, first of all nice forum. I have a task that i need to perform. I need to create and array which will store medicine when entered in by a user. the code i have so far is: import javax.swing.JOptionPane; public class ArrayDemo { public static void main(String[] args) { String[] anArray; // declare an array of integers anArray = ...

39. Arrays - JLS    coderanch.com

40. arrays?    coderanch.com

hello all. i am working on a program that decides if a word or a sentence is a palindrome. this is my first time using JOption. here is my code: import javax.swing.*; public class swain1Palindrome { public static void main (String[ ] args) { String inputSentence; int leftCharInputSentence, rightCharInputSentence; inputSentence = JOptionPane.showInputDialog(null, "Enter a sentence or word: "); getDecision(); getResponce(); private ...

41. arrays?    coderanch.com

hello all. i am working on a program that decides if a word or a sentence is a palindrome. this is my first time using JOption. here is my code: import javax.swing.*; public class Palindrome { public static void main (String[ ] args) { String inputSentence; int leftCharInputSentence, rightCharInputSentence; inputSentence = JOptionPane.showInputDialog(null, "Enter a sentence or word: "); getDecision(); getResponce(); private ...

42. # of items in an array    coderanch.com

43. Whak kind of array suits my needs better ?    coderanch.com

remove(0) in ArrayList is implemented by shifting all the remaining elements, so that may be what your coworker was pointing out. A LinkedList wouldn't have this problem, but I don't know what other operations you are doing on your list -- random access if O(N) on a linked list. In a dimly-lit corner of my brain, I seem to have the ...

44. Identifying subclass in an array    coderanch.com

I have created a multidimensional array of class Squares and am assigning some members of the array to a subclass (ie Hotel) of Squares. I need to be able to see what subclass, if any, has been assigned to the Square and then to perform operations on the square depending on which subclass it contains. Here is some of the code: ...

45. array    coderanch.com

46. Problem with arrays    coderanch.com

Hello, I am a java newbie and I couldn't find answer to this situation in any of the books available in my college. Please help understand this. How is it that I am not able to assign values to arrays outside of a method? class TestArrays { int classid; int studentids[]= int[10]; classid = 10; // I can assign values to ...

47. Help with privatizing array    coderanch.com

I have an class that consists of a main method, one other method and an array. It does exactly what I want if I structure it like so: public class MyClass { static String Name[]; public static void main( String[] args ) { name = new String[ 3 ]; name[ 0 ] = "Sam"; name[ 1 ] = "Bob"; name[ 2 ...

48. How can you make an array grow    coderanch.com

The size of an array is fixed. Your only option is to copy the values into a larger array using System.arraycopy and then assign the original reference to the larger array. Like this double[] values = new double[10]; //fill the array for (int i = 0; i < values.length; i++) { values[i] = i * i; } //oops now we need ...

49. Array problem.    coderanch.com

50. Next null in arrays?    coderanch.com

51. Array iteration/output problem    coderanch.com

52. another array problem    coderanch.com

private String status=null; public void checkEntryUpload(String lotnum) { try { con = new DBConnection().getConnection(); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM T_UPLOAD where LOTNUM='"+lotnum+"'"); while (rs.next()) { String acclevel = rs.getString("lotnum"); if(acclevel.equals(lotnum)) status = "found"; else status = "null"; } con.close(); rs.close(); stmt.close(); } catch (SQLException se) { System.out.println("SQL Exception: " + se.getMessage() + "not connected"); se.printStackTrace(System.out); } ...

53. Array and condition problem    coderanch.com

I have an array which contains the names of days read from a line in a test file which contains other information, such as time etc. For example, com1402, Dr Andy Gordon, Monday, 0900 (The purpose being to record when a lectuer is to take place) The code is written below for (counter=0; counter

54. Problems with outputting arrays    coderanch.com

When trying to output an array with System.out.println(DHand1[]); i get an error message '.class' expected import java.io.*; public class Cards { static int DHand1[] = new int[13]; //Creates the array /** Creates a new instance of Cards */ public static void main() { DHand1[2] = 15; //Assigns position 2 of the array with a value of 15 System.out.println(DHand1[]); } } Any ...

55. Naming Arrays    coderanch.com

I have an array called chromosomes of 20 Strings: String chromosomes = [chromosome0,chromosome1,chromosome3... chromosome19] I wish to loop through this array creating integer arrays of each String. The following code isn't valid due to incompatible types: for (int i = 0; i < 20; i ++) { String current = chromosomes[0]; current = new int[500]; } How can i name the ...

56. Adding a usedChar array in my program    coderanch.com

OK, I'm writing a Hangman program and it has three classes, Hangman, HangmanFileReader (it gets the words out of a file) and HangmanManager (which acts as a driver) The program runs 100% the way I want it, except for one thing: If the user guesses a letter they have guessed correctly or incorrectly before, it still subtracts from their chances left. ...

57. new to working with arrays    coderanch.com

I have a problem and would like to know how best to approach solving it. I have an array of strings that need to be put in reverse order. So I need to read the array the process it and reverse the strings.. any help would be great. Please let me know if there is anything that needs to be cleared ...

58. about arrays    coderanch.com

And think about the difference between the memory the array takes up and the memory the objects in the array take up. LargeObject[] array = new LargeObject[ONE_MILLION] The memory used by that is one million references or pointers which are only a few bytes each. Every one of them is null and points to nothing. That might well succeed without blowing ...

59. About array in Java    coderanch.com

60. Java array fundamentals    coderanch.com

You're trying to create an array of ints. For each position in the array you will need 32 bits (not 16) to store the int because the JLS defines the exact size of an int. So, for each int in your array you'll need four bytes. 2147483647 * 4 is 8589934588. Does your system have 8589934588 bytes of memory? No, of ...

61. final array    coderanch.com

import java.util.*; class MyObject { int x; MyObject(int x) { this.x = x; } public String toString() { return "MyObject_" + x; } } class UnMod { public static void main(String[] args) { LinkedList origList = new LinkedList(); MyObject my1 = new MyObject(1); MyObject my2 = new MyObject(2); origList.add(my1); origList.add(my2); System.out.println("Original List: " + origList); List unModList = Collections.unmodifiableList(origList); System.out.println("unMod List: ...

62. Help with an array    coderanch.com

hi i need some help with an array it says Hit uncaught exception java.lang.ArrayIndexOutOfBoundsException but im sure the index is ok package Chapter5; // Exercise 5.21 public class TotalHours { public static void main(String[] args) { int [][] hours = {{2,4,3,4,5,8,8},{7,3,4,3,4,4},{3,3,4,3,3,2,2}, {9,3,4,7,3,4,1},{3,5,4,3,6,3,8},{3,4,4,6,3,4,4}, {3,7,4,8,3,8,4},{6,3,5,9,2,7,9}}; int [][] totalhours = new int [8][2]; int x=0, y=0, max=0, maxIndex=0, number=0; for(x=0; x<=7; x++) { for(y=0; ...

63. Array item selection    coderanch.com

I want to select members of an array that lie between certain values. i.e. i have the array DHand1[0] = 3; DHand1[1] = 4; DHand1[2] = 15; DHand1[3] = 18; DHand1[4] = 25; DHand1[5] = 30; DHand1[6] = 31; DHand1[7] = 35; DHand1[8] = 37; DHand1[9] = 39; DHand1[10] = 42; DHand1[11] = 45; DHand1[12] = 51;

64. Array item selection    coderanch.com

I want to select members of an array that lie between certain values. i.e. i have the array here. how would i select only the members that lie between two values. For instance I want to select all elements whose value is between 1 and 13. DHand1[0] = 3; DHand1[1] = 4; DHand1[2] = 15; DHand1[3] = 18; DHand1[4] = 25; ...

65. Organizing an array    coderanch.com

hey im just having trouble with this array, its like it entirely misses the part where i swap the elements if one is bigger than the other and i cant figure it out package Chapter5; // Exercise 5.21 // This program adds the total hours from an array and organizes them from // smallest to biggest and then prints the employee ...

66. Yet another array problem :P    coderanch.com

well heres some more code with an array and im trying to multiply the matrixes of two arrays, i think its when i try to assign values to the array d and pass it back. it says the array is out of bounds but ive made sure to check everything and it seems just fine all the array have 5 elements ...

67. newbie help please with arrays    coderanch.com

I am struggling a little with a few ideas and concepts, and so my assignment is getting very behind. I cant seem to connect the right ways of accessing the data of one array from another, ie: importing the data from one to another. I want too create a copy of one array as another in a different class. Cant seem ...

68. another question on arrays    coderanch.com

hi, if this is a given array: Integer[] ir = {12, 45678, 90123, 3}; how do i rewrite this loop: for (int i=0; i

69. To export an array to a folder .txt    coderanch.com

Hello, I am creting a program in which a need to export the creted data in a folder .txt (or .dat). The data are save in an array type double. I need that somebody indicated to me the steps to create this file and the possible problems. You need more information?? It is possible an example code?? thanks!!

70. Array assignment    coderanch.com

Java does not directly support multidimensional arrays. It does allow us the functionality of multidimensional arrays by allows arrays of arrays. That is we can an array in which each element is another array. When calling a method or assigning a value, you have to make sure that what you acessing in the array is the correct type. I think your ...

71. Array Issue    coderanch.com

Yes an array is an Object but an Object is not necessarily an array. It doesn't matter whether or not the Object obj is actually an array of floats, if you declare it an Object then you cannot use it as if it were an array without casting it back to an array.

72. Returning an array    coderanch.com

Hi. I'm currently facing problems with this kind of thing: I need to do different kind of calculations and then return those results in a new array (I've one previous array but it doesn't affect to this?). How should I do this thing. Am I right if I say that I need first create a new array, then put those results ...

73. Arrays again :-(    coderanch.com

I'm trying to write a programme that'll create an Array, fill it up with elements, and then tell you.... 1. the elements that were entered. 2. how many times each element is contained in the Array. the user is prompted to enter the numbers one by one.... I've been going round in circles, and to be honest i dont know where ...

74. Array question    coderanch.com

I have an array of 5 JRadioButtons. I want a text field to display the integer value of the subscript. For example, if the Zeroth element radio button is selected, the text field will display 0. I'm not sure of the terminology, but is there a field associated with arrays that will yield this value? For example, the array is called ...

75. arrays    coderanch.com

Hi, I have a simple problem, I am trying to fill a 2d array 12 rows and five columns with unicode characters from 65 to 124 using nested for loops. I understand how the nested loops work but I cannot work out how to put the correct value into each array. I guess this is a simple math problem which is ...

76. An array problem    coderanch.com

When you pass an array as an argument to a function then it's a pass by reference. So what ever the changes you'll do in the function are reflected in the caller function also. Now in your code in function "treble" first line is int [] b =a; // assigning the refrence of a to be. Now what ever u'll do ...

77. "exists" method for arrays?    coderanch.com

if ( defined(args[5]) // What is defined() a method of? if ( exists(myArray[3]) ) { // What is exists() a method of? } if ( Rey[8] ) { // This doesn't work bcos only booleans are booleans in Java // null doesn't evaluate to false <>0 doesn't evaluate to true } if ( Mee[2] != null ) { System.out.println( "Mee Too!!" ...

78. working with arrays    coderanch.com

Hi there. I'm trying to do a few simple things with arrays of integers, but I'm having a bit of trouble. First, I'd like to write some code which returns true if two adjacent array elements have the same value, and it returns false otherwise. So as soon as it finds two matching entries (if they exist), it should return true. ...

79. Array problem    coderanch.com

I'm having one hell of a time with this problem using arrays. I realize this is long, but if anyone could help me with it I'd be so grateful. It's an assignment for class, and I've already turned it in as is below, but I spent two hours staring into the code and it just never came to me. I *have* ...

80. Creating an Array question    coderanch.com

I need to make an array that is subscripted by the letters 'A' through 'Z'. How do I do this? From what I can tell, I need to use the ASCII code for the letters, 65 through 90. The question is how do I make an array *not* start from 0? I want the array to go from 65 to 90. ...

81. arrays    coderanch.com

82. an array of buttons in an applet ?    coderanch.com

I have the following code and I know there must be a way to simplify it, I just don't know enough about Java to know how. Is there any way that you could create an array of buttons? That way I could just use a for loop to set their values, position, and create them. Thanks in advance! import java.awt.*; import ...

83. How to seperate an array    coderanch.com

Hi, I'm stuck on how to archive this....any help would be highly appericated! Thanks in advance! Let's say I have a string array: String[] tmpPattern = {"p1","p2","p3","p4","p5","p6","p7","p8","p9", "p10", "p11"}; and a header: String tmpHeader = "Header 1"; Need to print out ----> Header 1 p1 p2 p3 Header 1 p4 p5 p6 Header 1 p7 p8 p9 Header 1 p10 p11 ...

84. array re-initialization    coderanch.com

I have a following question. Suppose that I initialized an array like this: Object[] params = { new String (ProductName), new String(SupplierName) }; Suppose now I want the same type of array but with different values, though I cannot reuse it like this later on: Object[] params = { new String(SupplierId) }; Looks like now I need to either initialize the ...

85. Use of a two deminsional Array    coderanch.com

All, I am new to Java and I need to write a program which utilizes a class named video w/ two variables and a applications class named videostore which will sort 5 movies by title and corresponding Ratings. I have so far been able to get the movies sorted by title and displayed in an unsorted state and in alphabetical order. ...

86. Array Initilaize    coderanch.com

87. Understanding this Array?    coderanch.com

88. trouble with an array    coderanch.com

Hi, I am currently working on a project which is too create a FreeCell solitaire game. I am working on a class Pile (which is just a pile of cards). It involves making an array and implementing a few methods. This is my code so far public class Pile { private Deck deck; private Card[] pile; private int numCards; private static ...

89. Code for user input for multi arrays    coderanch.com

Hi, I'm still having problems coding for a multi dimensional array with user input. I have this code for the input: for(int i = 0; i < coffeeArray2.length; i ++) { for(int j = 0; j < coffeeArray2[i].length; j ++) System.out.print("Enter number of lbs of coffee for the first aisle:"); coffeeArray2[i][j] = myInput.nextInt(); But this is only getting me one column ...

90. Playing with Arrays    coderanch.com

Hi experts, i am playing a little bit around with arrays an I am stuck on this (my intention was to create some code as a framework for sorting experiments): class MyNumbers { double a[] = new double[100]; void fillArray () { for (int i = 0; i < 100; i++) a[i] = Math.random(); } void showMe() { System.out.println(a[1]); } } ...

91. emptying an array    coderanch.com

What kind of array are you using? If you have declared an array of ints (int[]), then you CANNOT use null as a value. The null value is only valid for object references. I think this is why you are confused. There is no way to "empty" an array of primitive values (such as int, char, etc.). Layne

92. Performing a swap within an array    coderanch.com

Hi all, I was wondering if someone could help. First let me start by saying that this problem is for a class. I have looked through some past posts but I am not sure I am looking for the right thing. The problem is I need to make a code that will swap the first and last characters in an array. ...

93. Array Question    coderanch.com

Hi, please look at the code below:- --------------------------------- public class a { // comparing 2 arrays public static void main (String args[]) { int array1 [] = {1,2}; // array1 int array2 [] = {1,2}; // array2 if (array1 == array2) System.out.println("same"); } // ~main() } // ~class --------------------------------- 1. Why doesn't it print same? 2. Also, how do I compare ...

94. Array Help    coderanch.com

95. Strign of arrays    coderanch.com

96. An array question    coderanch.com

First, I'm reading through the Head First book to teach myself Java. There's my disclaimer. Ok, I think I understand arrays as the book explains them (and as a friend once told me). Java treats an array as an object, that holds values in an indexed manner so it's easily referenced? Now, an array of objects would only hold the references ...

97. How to know if type is array or not    coderanch.com

98. Trying to show pics from array.    coderanch.com

I have a program which responds to button presses with a series of sounds and associated pictures, each with it's own pause duration. The problem was that no pictures would be displayed until the code exited the button's action listener thread. As such someone suggested creating an animator control - basically a label with a timer and an associated array of ...

99. Initializing Arrays    coderanch.com

Note that the first style is only possible if you're declaring and initializing the array in the same statement. This here does not work: int[] info; info = {2000, 100, 40, 60}; The reason is that Java's designers wanted to ensure that it's very clear what type the array has. If the type "int[]" appears on the same line as the ...

100. best way to find duplicates on array    coderanch.com

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - ...

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.