Solved

java programming

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
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:

789 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