Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > reflect field

Reply
Thread Tools

reflect field

 
 
ZaRMaS@gmail.com
Guest
Posts: n/a
 
      12-21-2006
Hi all,

I want to get value of string variable in a class, and field it with
new strings like this :

EXample

public class helloWold()
{
String myString1 = "test1";
String myString2 = "test2";
String myString3 = "test3";
String myString4 = "test4";
}


public static void main(String[] args) {
Field myField[] = helloWold().class.getFields();

for (int i = 0; i < myField.length; i++)
{
System.out.println(myField[i].getName()); //get value
}
}

Actually I get the value, but i didn't know how to field it. I try the
method set but i have an error
'an not set java.lang.String field to java.lang.String'

Any ideas

Thanks.

Merci d avoir lu et de vos idees par avance

 
Reply With Quote
 
 
 
 
wesley.hall@gmail.com
Guest
Posts: n/a
 
      12-21-2006

http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Hi all,
>
> I want to get value of string variable in a class, and field it with
> new strings like this :
>
> EXample
>
> public class helloWold()
> {
> String myString1 = "test1";
> String myString2 = "test2";
> String myString3 = "test3";
> String myString4 = "test4";
> }
>
>
> public static void main(String[] args) {
> Field myField[] = helloWold().class.getFields();
>
> for (int i = 0; i < myField.length; i++)
> {
> System.out.println(myField[i].getName()); //get value
> }
> }
>
> Actually I get the value, but i didn't know how to field it. I try the
> method set but i have an error
> 'an not set java.lang.String field to java.lang.String'
>
> Any ideas


You know, it amazes me how many people post in this group asking for
help and say something like...

"I wrote this code (which I have posted), it works.... but some other
code (which I haven't posted) doesn't work. Please help!".

I am starting to understand why Andrew Thompson is always grumpy

 
Reply With Quote
 
 
 
 
Phi
Guest
Posts: n/a
 
      12-21-2006
(E-Mail Removed) wrote:
> (E-Mail Removed) wrote:
>> Hi all,
>>
>> I want to get value of string variable in a class, and field it with
>> new strings like this :
>>
>> EXample
>>
>> public class helloWold()
>> {
>> String myString1 = "test1";
>> String myString2 = "test2";
>> String myString3 = "test3";
>> String myString4 = "test4";
>> }
>>
>>
>> public static void main(String[] args) {
>> Field myField[] = helloWold().class.getFields();
>>
>> for (int i = 0; i < myField.length; i++)
>> {
>> System.out.println(myField[i].getName()); //get value
>> }
>> }
>>
>> Actually I get the value, but i didn't know how to field it. I try the
>> method set but i have an error
>> 'an not set java.lang.String field to java.lang.String'
>>
>> Any ideas

>
> You know, it amazes me how many people post in this group asking for
> help and say something like...
>
> "I wrote this code (which I have posted), it works.... but some other
> code (which I haven't posted) doesn't work. Please help!".
>
> I am starting to understand why Andrew Thompson is always grumpy
>

I just had a closer look at java reflection and java.beans. I probably
could help you, but I need some more input:

What do you mean with "how to field it"?
And what do you mean with a "method set": Your code returns a Field-Set
and not a Method-Set.

phi
 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      12-21-2006
(E-Mail Removed) wrote:
> You know, it amazes me how many people post in this group asking for
> help and say something like...
>
> "I wrote this code (which I have posted), it works.... but some other
> code (which I haven't posted) doesn't work. Please help!".
>
> I am starting to understand why Andrew Thompson is always grumpy


He's not grumpy, he's direct.

And helpful. It's good to know that people will get educated about top
posting, multiposting vs. crossposting, sccces, meaningful subject lines and
associated netiquette even when they don't/won't read the FAQs.

- Lew
 
Reply With Quote
 
wesley.hall@gmail.com
Guest
Posts: n/a
 
      12-21-2006

Lew wrote:
> (E-Mail Removed) wrote:
> > You know, it amazes me how many people post in this group asking for
> > help and say something like...
> >
> > "I wrote this code (which I have posted), it works.... but some other
> > code (which I haven't posted) doesn't work. Please help!".
> >
> > I am starting to understand why Andrew Thompson is always grumpy

>
> He's not grumpy, he's direct.
>
> And helpful. It's good to know that people will get educated about top
> posting, multiposting vs. crossposting, sccces, meaningful subject lines and
> associated netiquette even when they don't/won't read the FAQs.
>
> - Lew


I know, I was just kidding, hence the emoticon )

 
Reply With Quote
 
Daniel Pitts
Guest
Posts: n/a
 
      12-21-2006

(E-Mail Removed) wrote:
> (E-Mail Removed) wrote:
> > Hi all,
> >
> > I want to get value of string variable in a class, and field it with
> > new strings like this :
> >
> > EXample
> >
> > public class helloWold()
> > {
> > String myString1 = "test1";
> > String myString2 = "test2";
> > String myString3 = "test3";
> > String myString4 = "test4";
> > }
> >
> >
> > public static void main(String[] args) {
> > Field myField[] = helloWold().class.getFields();
> >
> > for (int i = 0; i < myField.length; i++)
> > {
> > System.out.println(myField[i].getName()); //get value
> > }
> > }
> >
> > Actually I get the value, but i didn't know how to field it. I try the
> > method set but i have an error
> > 'an not set java.lang.String field to java.lang.String'
> >
> > Any ideas

>
> You know, it amazes me how many people post in this group asking for
> help and say something like...
>
> "I wrote this code (which I have posted), it works.... but some other
> code (which I haven't posted) doesn't work. Please help!".
>
> I am starting to understand why Andrew Thompson is always grumpy


Strangly enough, the code the OP posted is NOT valid Java code by any
means.

 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript validation for a not required field, field is onlyrequired if another field has a value jr Javascript 3 07-08-2010 10:33 AM
Help me, problem with java.lang.reflect.Field Nicky Java 3 01-25-2007 09:21 AM
1.Enter space bar for field names and save the field.The field shoud not get saved and an alert should be there as"Space bars are not allowed" Sound Javascript 2 09-28-2006 02:43 PM
Problem with reflect list jonr944@hotmail.com Cisco 2 06-05-2005 03:37 PM
Data Grid does not reflect an update or insert. Sunil Thomas ASP .Net 0 09-29-2003 06:59 PM



Advertisments