Solved

java programming

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
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 …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now