Wayne Sheets

Greenhorn
+ Follow
since Feb 27, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
4
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Wayne Sheets

Jeff Verdegan[Or just create the "inner" String array inside the loop. [/quote wrote:

I used this method. Its works great... thanks!

12 years ago

Jeff Verdegan wrote:
The above puts a reference to that one single String array that was ever created into the current element of the data array.

In other words, you're only ever creating one array of Strings, and then you keep replacing its contents with the new Strings from each line, and then all the "outer" elements of your 2D array point to that same single String[] object.

You need to create a new String[] for each row.


When you do x = y with reference variables in Java, it only ever copies the reference, never the object, so the result of that assignment will simply be two reference variables pointing to the same object.



That makes a little more sense. Thanks.
12 years ago

Henry Wong wrote:Remember that java technically doesn't have 2D arrays. It has arrays of arrays. So, this statement...



Is assigning the element of the outer array to point to the row array -- the previous row is now eligible for GC. And of course, by the time the loop is done, all the elements will refer to the same row array.

Henry



Thanks for the reply. I understand what you're saying.

Whats the best way then to transfer the contents of row into data?
12 years ago
I'm trying to read a fixed size csv file.
Please check the code comments.




Any help?

Thanks.
12 years ago
Thanks for the answers guys. It helps a lot!

[EDIT] A forum that links grammatically incorrect words! Awesome!
12 years ago

Roberto Perillo wrote:Greetings, Wayne. Welcome to JavaRanch!

Please CarefullyChooseOneForum when you post a question. Posting your question to the right forum helps keep it well organized, and everybody can benefit from the discussion. Since this has more to do with Java Swing, let's slide it over there



Understood. Thanks.
12 years ago
Here's the deal. I have two JLabels. One of them is a large image.

When I click on the smaller label, it is 'glued' to the mouse. Meaning it moves to where ever the mouse pointer takes it.
When the mouse is clicked again, the label is 'unglued' and stays where it was dropped.

The idea is that this small label needs to be dropped onto the large label.
The problem is that the small label is behind the large label. I cant seem to bring it to the front.

I'm not using a layout manager (setLayout(null)).

Any ideas?

Thanks.
12 years ago