Results 1 to 2 of 2
  1. #1
    hasysf is offline Member
    Join Date
    Jul 2008
    Posts
    19
    Rep Power
    0

    Default how to find a datatype

    I have a project that i am working on and i am stuck in a method

    i have a Comparable arraylist which look like this
    Comparable tuple[1,"abc","xyz",23]

    and thier domains are given in another array as
    Class [] domain =new Class {int, string, string, int}

    My question is that is there any way i can find the datatypes of the first list values ??
    Also after finding the datatypes compare them with the below list to make sure that they are of right datatype

    Any help would be appreciated
    thanks

  2. #2
    devunion is offline Member
    Join Date
    Jun 2008
    Posts
    56
    Rep Power
    0

    Default

    This will work:

    Java Code:
        Comparable[] list = new Comparable[] {1, "123", "qwe", 4}; 
        for (Comparable c : list) {
             System.out.println("c.getClass() = " + c.getClass().getName());
        }
    You can compare classes or their names. Use Integer.TYPE for int and String.class for strings.
    Try Controls4J - Advanced Swing Components.

Similar Threads

  1. Cannot find 'Dataset'
    By mgm2010 in forum New To Java
    Replies: 2
    Last Post: 06-04-2009, 12:56 PM
  2. Problem in using Object datatype
    By mfaizan24 in forum New To Java
    Replies: 6
    Last Post: 05-06-2009, 12:51 AM
  3. Problems with a complex datatype in a webservice
    By lichtbringer in forum Web Frameworks
    Replies: 2
    Last Post: 10-29-2008, 06:32 AM
  4. can't find tamplate.tld anywhere
    By amu in forum Advanced Java
    Replies: 1
    Last Post: 10-15-2008, 03:15 PM
  5. Where to find wsimport
    By javaplus in forum Web Frameworks
    Replies: 1
    Last Post: 11-26-2007, 10:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •