Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 4th October 2008, 09:02
CMYK CMYK is offline
Junior Member
Join Date: Sep 2008
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default array allocation question in java

In my source code for a mathematical project and I'm running into a problem that ends with a duplicate variable names error. In my function I take a string as an argument to be the name of a new array that will be allocated. Here's what the source code looks like
private static void somefunction(String name) {
int name[] = new int[10];
I need to call that function at least twice and I think that the compiler is getting confused and tries to allocate an array by the name of name instead of the string I provide as an argument. When it gets called the second time it tries to allocate name[] again and javac raises the error.
Does anyone know how I could tell Java to name the array what I provide as an argument?
Reply With Quote
Sponsored Links


array, dynamic allocation, java

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to cast a char ptr to an array (to prevent warning, it does work) Owen_Townsend Programming/Scripts 0 4th September 2008 02:12
Debian: Failed Raid5 Array & Kernal Panic snowfly Installation/Configuration 0 29th August 2007 13:52
Warning: fwrite(): supplied argument is not a valid stream resource Salvis General 7 4th July 2007 16:43
log files, rotation and emailing them hairydog2 General 65 11th October 2006 14:18
phpMyAdmin - panick attack md@waw.co.uk General 6 3rd September 2006 21:52

All times are GMT +2. The time now is 11:29.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.