LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-16-2004, 03:42 AM   #1
black
Member
 
Registered: Jul 2002
Location: nowhere
Distribution: GNU
Posts: 118

Rep: Reputation: 15
how to concatenate variable name in Java ?


hi all~

i have no idea how to combine variable names in Java, for example i know i want to output the variable named msg0, msg1, msg2...etc, how can i do this like below:

Code:
for (int i=0; i<10; i++)
{
    System.out.println(msg+i);
}
regards~
 
Old 11-16-2004, 04:08 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Although this kind of construction is frequently supported with interpreted languages, it can't be used with compiled languages like java or C.
Better use an array or some sort of collection objects.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
java variable redhatrosh Programming 6 03-17-2005 10:55 AM
java and PATH variable qwijibow Linux - Newbie 1 05-26-2003 03:43 PM
setting java VM environnement variable sgroy45 Linux - General 2 12-22-2002 10:51 AM
how to get environmental variable from JAVA program edreddy Programming 2 07-29-2002 10:38 AM
ClASSPATH variable for Java oulevon Linux - General 1 02-28-2001 08:25 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration