|
| ||||||||||
| Tags: attribute, calling function, datatype, integer, string |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Retrieve attribute as string
I want to retrieve the name of an attribute in a string Example: Code: int size = 3; String str = "Size"; |
|
#2
| |||
| |||
| Re: Retrieve attribute as string
Hello, I think you can make a code similar to this Here is the general form of the code Code: Field e = ... ... e.getClass().getCanonicalName(); |
|
#3
| |||
| |||
| Re: Retrieve attribute as string
Hello, Even I was trying a similar kind of a program, I used you solution and thanks I found what I wanted. If you do not mind one more question. I want to retrieve the name of the instance of a class (the object name what). Code: public class mcls ( ... display the instance name ... } public static void main (String [] args) ( inst mcls = new mcls (); } |
|
#4
| |||
| |||
| Re: string as an attribute
Hello, If it's just to test and see who called your Standings, you can do: Code: Exception ex = new Exception(); ex.printStackTrace(); |
|
#5
| |||
| |||
| Re: Retrieve attribute as string
Hello, Basically recover "inst" has no meaning in the sense there in the code. The variable name is the name of the instance pointer, so the body can not know the variables that reference. And if you approach it in your body that you do for a variable. Is that clear enough? If you are not understanding this then I am sorry you have to read some basics of java first and then try to implement the code or try coding. |
|
#6
| |||
| |||
| Re: Retrieve attribute as string
Hello, I am new to java and I do not exactly know what you need, but I have a sample code with me, see if this helps you. Here is the code Code: String str="some text";
String vldch="some ";
str=str.toLowerCase(); // case desense!
for (int i=0;i<str.length();i++)
{
char c=str.charAt(i);
if (vldch.indexOf(c)==-1)
{System.out.printf(" character["+c+"] at position "+i);}
} |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Retrieve attribute as string" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to set file attribute? | Julli_gaada | Tips & Tweaks | 3 | 21-11-2009 07:05 PM |
| How to retrieve a substring in a string? | Protector | Software Development | 3 | 15-10-2009 07:20 PM |
| How to Manipulate String using PHP String Functions | ComPaCt | Software Development | 3 | 21-09-2009 09:07 AM |
| How to set HTML Tag Attribute in asp.net | Shashee | Software Development | 3 | 08-06-2009 10:39 PM |
| Custom AD attribute - [WP] | OmJaa | Active Directory | 3 | 11-03-2008 07:17 PM |