Solved

java programming

Posted on 2004-10-02
4
172 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

Suggested Solutions

Title # Comments Views Activity
ejb stateless example 2 66
How to convert from xls to xlsx using java 7 149
SequenceInputStream example 3 37
junit example issue 2 54
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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 one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

739 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