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

    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

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


    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, 11:56 AM
  2. Problem in using Object datatype
    By mfaizan24 in forum New To Java
    Replies: 6
    Last Post: 05-05-2009, 11:51 PM
  3. Problems with a complex datatype in a webservice
    By lichtbringer in forum Web Frameworks
    Replies: 2
    Last Post: 10-29-2008, 05:32 AM
  4. can't find tamplate.tld anywhere
    By amu in forum Advanced Java
    Replies: 1
    Last Post: 10-15-2008, 02:15 PM
  5. Where to find wsimport
    By javaplus in forum Web Frameworks
    Replies: 1
    Last Post: 11-26-2007, 09: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