Solved

java programming

Posted on 2004-10-02
4
173 Views
Last Modified: 2010-03-31
TreeSet trList = new TreeSet();
for(int i=0;i<ff.length;i++)
         {
Class cc=Class.forName(className);
Field[] ff=cc.getDeclaredFields();
Class type =ff[i].getType();


                    if(type.isPrimitive()==false)
                    {
                    String fqName = type.toString();
                    int x=fqName.length();
                    String cName = fqName.substring(fqName.lastIndexOf(".")+1,x);
                    System.out.println("class name="+cName);
                                                  trList.add(cName);
                    String packageName = fqName.substring(0, fqName.lastIndexOf("."));
              System.out.println("packagename="+packageName);
                           }
 }

Can we store packageName in a package TreeSet?
0
Comment
Question by:sraveend
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 250 total points
ID: 12208889
sraveend, you've already been asking about this sort of thing. What do you mean by this? What's wrong with

trList.add(packageName);

?
0
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
ID: 12209210
try this:


TreeSet trList = new TreeSet();
TreeSet packages = new TreeSet();
for(int i=0;i<ff.length;i++)
         {
Class cc=Class.forName(className);
Field[] ff=cc.getDeclaredFields();
Class type =ff[i].getType();


                 if(type.isPrimitive()==false)
                 {
                 String fqName = type.toString();
                 int x=fqName.length();
                 String cName = fqName.substring(fqName.lastIndexOf(".")+1,x);
                 System.out.println("class name="+cName);
                                                  trList.add(cName);
                 String packageName = fqName.substring(0, fqName.lastIndexOf("."));
              System.out.println("packagename="+packageName);
                 packages.add(packageName);
                       }
 }
0
 

Author Comment

by:sraveend
ID: 12209976
Sorry there was a small misunderstanding......
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12210821
8-)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question