?
Solved

java programming

Posted on 2004-10-02
4
Medium Priority
?
174 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 750 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 750 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses
Course of the Month9 days, 17 hours left to enroll

762 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