Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to Convert a string to variable name in Java

807601Apr 4 2008 — edited Apr 10 2008
Hi ever body,
How can I use a string to name a variable?

for example for those who know php


<?php

$a = 5;

$b = ${'a'};

echo $b;

// and the output will be 5

?>
I need to do the same thing in Java but i don't know how
Thank you in advance
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 8 2008
Added on Apr 4 2008
19 comments
9,011 views