Why how Abstract class   for java.util.set

I need to use Set i din't find any impelemnted class for Set, i don't want HashSet or LinkedHashSet just a Set is enough for my purpose.
How can i take instance of AbstractSet it is abstract.....
Is the only way is to write my own class extending AbstractSet.
Or is there something which i'm missing
TIA Nas

Because Vector isn't an ancsetor of AbstractList.
What you are trying to do is the same as saying that becasue my cousin and I have the same grandfather we must have the same parent which isn't true.
           Collection
        Set         List
   AbstractSet      AbstractList
   HashSet              Vector

Similar Messages

  • Puzzled by the redefinition of the methods in java.util.Set

    Hi all,
    I don't understand why those methods in java.util.Set redefined since their counterparts have alrealdy been defined in java.util.Collection and java.util.Set extends java.util.Collection. I agree to redefine boolean add(Object o) because its contract has been modified, but what about the rest like
    size() and iterator() ?
    Thanks.

    Hi all,
    I don't understand why those methods in
    in java.util.Set redefined since their counterparts
    have alrealdy been defined in java.util.Collection
    and java.util.Set extends java.util.Collection. I
    agree to redefine boolean add(Object o) because its
    contract has been modified, but what about the rest
    like
    size() and iterator() ?Completeness's sake?
    ~Cheers

  • Why interfaces why not abstract classes?

    why they are using interfaces concept in JDBC or struts2.0 why not abstract classes?
    thanks in advance.

    user5287726 wrote:
    jverd wrote:
    user5287726 wrote:
    Interfaces are more flexible. For certain definitions of flexible, yes, but not for others.
    A Java class can only inherit one class, but it can implement multiple interfaces.Which has absolutely nothing to do with why JDBC declares interfaces rather than abstract classes.How does your post even attempt to answer the OP's question?OP asked: "why they are using interfaces concept in JDBC or struts2.0 why not abstract classes?" I'm pointing out that your post does not address the question asked. And of course your answer is wrong anyway.
    As for addressing the OP's question, I did that in my first response.

  • ADF Faces af:table support java.util.Set

    I was using a java.util.Set in my model classes, as implementation of the Collection interface. And wanted to show the Set using a <af:table> after a while I discoverded that the documentation did not mention support of java.util.Set, only List.
    Now I have to convert my collection to List in the backing beans of my view.
    Is there a better approch than converting every Set in the view using
    new Arraylist(set)?
    And what is the reason of the missing Set support (or General Colelction support)?
    Thank you

    Deepak, I don't think you know what you're writing about.
    No, we do not support java.util.Set in <af:table>. For that matter, neither does <h:dataTable>.
    The "why" of it is that we require indexed access into the table for operations like "Display rows 526-550". java.util.Set does not offer indexed access.
    By the way, one corollary - do not use java.util.LinkedList with tables (ADF Faces or the JSF data table). If the list is small, then it won't be a problem, but with a large list, you'll get brutal performance.

  • OracleLog.properties for java.util.logging

    In the Oracle JDBC FAQ the answer to the question "How do I configure java.util.logging to get useful trace output from Oracle JDBC?" <http://otn.oracle.com/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm#36_03> mentions the file "OracleLog.properties" provided in the "demo.zip" file.
    I cannot find the file "OracleLog.properties" anywhere?
    Any suggestions?
    Kindest Regards,
    Gerhard Hofmann

    It seems a logger instance HAS been created for my Test class, I've added the lines below. Though it didn't appear in the logger names enumeration.
    java.util.logging.Logger logger = java.util.logging.Logger.getLogger(name);
    System.out.println(logger.getName()+"="+logger.getLevel().getName());
    logger.severe("severe");
    logger.warning("warning");
    logger.info("info");
    logger.config("config");
    logger.fine("fine");
    logger.finer("finer");
    logger.finest("finest");Output:Test=FINEST
    6/10/2003 16:00:01 Test <init>
    SEVERE: severe
    6/10/2003 16:00:01 Test <init>
    WARNING: warning
    6/10/2003 16:00:01 Test <init>
    INFO: infoObservations:
    1) Despite my Test class having the FINEST log level, the default ConsoleHandler had log level of INFO, and hence only up to INFO logged.

  • How can I define "java.util.ResourceBundle" in my Code ?

    Dear Mr. MLRon,
    Thanks to you for your replying to me.
    How can I define "java.util.ResourceBundle" in my Code ? To more understanding about my problem I can say that the Persian Font is Like as Arabic, but the Java can not Recognize it. please tell me how can I add "java.util.ResourceBundle" to my code and what should I do then?
    Thank you in advance,
    Tantan.

    Please stop starting new threads for this. Please reply in the original thread!
    http://forum.java.sun.com/thread.jspa?threadID=627917

  • Using ExecutorService class from java.util.concurrent package

    Dear java programmers,
    I have a question regarding the ExecutorService class from java.util.concurrent package.
    I want to parse hundreds of files and for this purpose I'm implementing a thread pool. The way I use the ExecutorService class is summarized below:
    ExecutorService executor = Executors.newFixedThreadPool(10);
            for (int i = 0; i < 1000; i++){
                System.out.println("Parsing file No "+i);
                executor.submit(new Dock(i));
            executor.shutdown();
            try {
                executor.awaitTermination(30, TimeUnit.SECONDS);
            } catch (InterruptedException ex) {
                ex.printStackTrace();
            executor.shutdownNow();However, the code snippet above creates all the 1000 threads (Dock objects) at once and loads them to the executor, and thus I'm worrying about memory leak. I haven't tested it on 1000 files yet but just on 50 small ones, and even if the program prints out "Parsing file No "+i 50 times at once, it executes normally the threads in the background.
    I guess the write way would be to keep the number of active/idle threads in the executor constant (lets say 20 if the thread pool's size is 10) and submit a new one whenever a thread has been finished or terminated. But for this to happen the program should be notified someway whenever a thread is done. Can anybody help me do that?
    thanks in advance,
    Tom

    Ok I found a feasible solution myself although I'm not sure if this is the optimum.
    Here's what I did:
            ExecutorService executor = Executors.newFixedThreadPool(10);
            Future<String> future0, future1, future2, future3, future4, future5, future6, future7, future8, future9;
            Future[] futureArray = {future0 = null, future1 = null, future2 = null, future3 = null, future4 = null, future5 = null,
            future6 = null, future7 = null, future8 = null, future9 = null};
            for (int i = 0; i < 10; i++){
                futureArray[i] = executor.submit(new Dock(i));
            }I created the ExecutorService object which encapsulates the thread pool and then created 10 Future objects (java.util.concurrent.Future) and added them into an Array.
    For java.util.concurrent.Future and Callable Interface usage refer to:
    [http://www.swingwiki.org/best:use_worker_thread_for_long_operations]
    [http://www.particle.kth.se/~lindsey/JavaCourse/Book/Part1/Java/Chapter10/concurrencyTools.html]
    I used a Future[] Array to make the code neater. So after that I submitted -and in this way filled up- the first 10 threads to the thread pool.
            int i = 9;
            while (i < 1000){
                for (int j = 0; j < 10; j++){
                    if (futureArray[j].isDone() && i < 999){
                        try{
                            i++;
                            futureArray[j] = executor.submit(new Dock(i));
                        } catch (ExecutionException ex) {
                            ex.printStackTrace();
                        } catch (InterruptedException ex) {
                            ex.printStackTrace();
                try {
                    Thread.sleep(100); // wait a while
                } catch(InterruptedException iex) { /* ignore */ }
            executor.shutdown();
            try {
                executor.awaitTermination(60, TimeUnit.SECONDS);
            } catch (InterruptedException ex) {
                ex.printStackTrace();
            executor.shutdownNow();
        }Each of the future[0-9] objects represents a thread in the thread pool. So essentially I'm check which of these 10 threads has been finished (using the java.util.concurrent.Future.isDone() method) and if yes I replenish that empty future[0-9] object with a new one.

  • Failed to unmarshal interface java.util.Set

    I am trying to get all mbeans using getAllMBeans() method after
    getting MBeanHome successfully. The method fails with the following
    error.
    Any clues ?
    Thanks
    karthik
    >>>>
    weblogic.rmi.extensions.RemoteRuntimeException: Unexpected Exception -
    with nested exception:
    [java.rmi.UnmarshalException: failed to unmarshal interface
    java.util.Set; nested exception is:
         java.io.InvalidClassException: javax.management.MBeanAttributeInfo;
    local class incompatible: stream classdesc serialVersionUID =
    7043855487133450673, local class serialVersionUID =
    8644704819898565848]
         at weblogic.management.internal.AdminMBeanHomeImpl_WLStub.getAllMBeans(Unknown
    Source)

    I am trying to get all mbeans using getAllMBeans() method after
    getting MBeanHome successfully. The method fails with the following
    error.
    Any clues ?
    Thanks
    karthik
    >>>>
    weblogic.rmi.extensions.RemoteRuntimeException: Unexpected Exception -
    with nested exception:
    [java.rmi.UnmarshalException: failed to unmarshal interface
    java.util.Set; nested exception is:
         java.io.InvalidClassException: javax.management.MBeanAttributeInfo;
    local class incompatible: stream classdesc serialVersionUID =
    7043855487133450673, local class serialVersionUID =
    8644704819898565848]
         at weblogic.management.internal.AdminMBeanHomeImpl_WLStub.getAllMBeans(Unknown
    Source)

  • Super class for java Language

    which is the super class for java Language...
    this is an interview question .
    I SAY Object is the super class for java Language ...
    then he asked whether object class will extend ??
    i say Yes it will implectly extend ...
    then he whether each and every class will extend object
    i say yes ...
    then he asked multiple inheritance is possible in java ...
    i say no ...
    then how will say object class will extend in each and every class....
    hai friends if there is any solution tell mem
    by
    dhana

    which is the super class for java Language...
    this is an interview question .
    I SAY Object is the super class for java Language
    ge ...If you mean the ultimate parent of all classes, yes.
    (Although it's not the parent of interfaces.)
    then he asked whether object class will extend ??
    i say Yes it will implectly extend ...Not sure what is meant by "will object extend."
    then he whether each and every class will extend
    object
    i say yes ...Correct.
    then he asked multiple inheritance is possible in
    java ...
    i say no ...Correct. At least in the usual sense. When people talk about multiple inheritance, the usually mean multiple inheritance of implementation, such as C++ supports. The ability to implement more than one interface in Java is sometimes referred to as multiple inheritance of interface. I don't know if that term is in common use outside of Java.
    then how will say object class will extend in each
    and every class....
    hai friends if there is any solution tell memMultiple inheritance means that a class' ancestors are not all in a straight line to the ultimate parent. That is, not all ancestors are parents or children of each other.
    You are you father's son, and he is his father's son, and so on. So your grandfather is your ancestor, and so is your father. This is not MI.
    You also have a mother. She's neither an ancestor nor a descendant of your father. That's MI.

  • TestNG with java.util.Set

    hi, i want to test simple method:
    @Parameters({"lista"})
    @Test
    public GroupedFiles groupFiles(Set<File> p_files){
    }and i have definition of my xml:
    <suite name="My suite">
      <parameter name="first-name"  value="Cedric"/>
      <test name="Simple example">
      <-- ... -->and my testNG throws me uknown for me exception:
    java.lang.AssertionError: Unsupported type parameter : interface java.util.Set
    could anyone help me with this case, thanks for any knowledge

    'little code modification'
    hi, i want to test simple method:
    @Parameters({"lista"})
    @Test
    public GroupedFiles groupFiles(Set<File> p_files){
    }and i have definition of my xml:
    <suite name="My suite">
      <parameter name="lista"  value="java.util.Set"/>
      <test name="Simple example">
      <-- ... -->and my testNG throws me uknown for me exception:
    java.lang.AssertionError: Unsupported type parameter : interface java.util.Set
    could anyone help me with this case, thanks for any knowledge

  • Getting compilation error: java.util.Set is an interface. This interface is not supported.

    Hi Folks,
    Is there a limitation in BEA's web services implementation? I have a simple web
    service that returns an array of java objects. However I am calling another middle
    tier API that returns a Set. I convert this Set into array of object and return
    it via the web service.
    However the .jws file that implements the webservice does not compile. I get the
    following error message:
    java.util.Set is an interface. This interface is not supported.
    Is there a limitation on using Collections within the .jws file? If that is the
    case it is a severe limitation.
    Note my Web Service API returns an array of java objects with no collections in
    them.
    Sanjay

    Hello,
    Generic java collections can only be handled in a very generic, weakly
    typed manner.
    Take a look at the
    http://workshop.bea.com/xmlbeans/guide/conXMLBeansSupportBuiltInSchemaTypes.html
    and also
    http://workshop.bea.com/xmlbeans/guide/conJavaTypesGeneratedFromUserDerived.html
    You might also ask your question to the XMLBeans newsgroup:
    http://newsgroups.bea.com/cgi-bin/dnewsweb?cmd=xover&group=weblogic.developer.interest.xmlbeans
    Regards,
    Bruce
    Sanjay wrote:
    >
    Hi Folks,
    Is there a limitation in BEA's web services implementation? I have a simple web
    service that returns an array of java objects. However I am calling another middle
    tier API that returns a Set. I convert this Set into array of object and return
    it via the web service.
    However the .jws file that implements the webservice does not compile. I get the
    following error message:
    java.util.Set is an interface. This interface is not supported.
    Is there a limitation on using Collections within the .jws file? If that is the
    case it is a severe limitation.
    Note my Web Service API returns an array of java objects with no collections in
    them.
    Sanjay

  • RFC used for java.util.regex

    Hi,
    Does anyone know the RFC used for java.util.regex ??
    Thanks & Regards,
    Gurushant Hanchinal

    Can you please give me the link to view to specifications for java.util.regex.. I have tried the link which is available in :
    http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html page with name " Java Language Specification"
    on click of this link, i am getting page not found error..
    Please give me any other alternate links to view the regular expression specifications..
    Thanks,
    Gurushant Hanchinal

  • Most commenly used abstract class in java.

    hi all,
    can anyone please tell me, what is most commonly used abstract class in java. this question was asked in interview.

    I hate interviewers when they ask about specifics of some classes.The fact that you hate it doesn't automatically follow that it's a bad question from the perspective of the person conducting the interviewer. You don't know what the real question is.
    Bad "real" question: Do you know the statistics of Java usage off the top of your head?
    Good "real" question: Do you know that Object isn't Abstract and can you name a few Abstract classes off the cuff?
    Even then Programmers are so literal minded - the real question may be "Talk about what you know a bit."

  • Does anyone know of any Sun Classes for Java Cryptographic Extension -JCE ?

    Hello - anyone know of any Sun Classes for Java Cryptographic Extension? If so do you have the Sun class code/s?
    Edited by: Mister_Schoenfelder on Apr 17, 2009 11:31 AM

    Maybe this can be helpful?
    com.someone.DESEncrypter
    ======================
    package com.someone;
    import java.io.IOException;
    import java.io.UnsupportedEncodingException;
    import java.security.spec.AlgorithmParameterSpec;
    import java.security.spec.KeySpec;
    import javax.crypto.Cipher;
    import javax.crypto.IllegalBlockSizeException;
    import javax.crypto.KeyGenerator;
    import javax.crypto.SecretKey;
    import javax.crypto.SecretKeyFactory;
    import javax.crypto.spec.PBEKeySpec;
    import javax.crypto.spec.PBEParameterSpec;
    public class DESEncrypter {
        Cipher ecipher;
        Cipher dcipher;
        // 8-byte Salt
        byte[] salt = {
            (byte)0xA9, (byte)0x9B, (byte)0xC8, (byte)0x32,
            (byte)0x56, (byte)0x35, (byte)0xE3, (byte)0x03
        // Iteration count
        int iterationCount = 19;
        public DESEncrypter(String passPhrase) {
            try {
                // Create the key
                KeySpec keySpec = new PBEKeySpec(passPhrase.toCharArray(), salt, iterationCount);
                SecretKey key = SecretKeyFactory.getInstance(
                    "PBEWithMD5AndDES").generateSecret(keySpec);
                ecipher = Cipher.getInstance(key.getAlgorithm());
                dcipher = Cipher.getInstance(key.getAlgorithm());
                // Prepare the parameter to the ciphers
                AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, iterationCount);
                // Create the ciphers
                ecipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
                dcipher.init(Cipher.DECRYPT_MODE, key, paramSpec);
            } catch (java.security.InvalidAlgorithmParameterException e) {
                 e.printStackTrace();
            } catch (java.security.spec.InvalidKeySpecException e) {
                 e.printStackTrace();
            } catch (javax.crypto.NoSuchPaddingException e) {
                 e.printStackTrace();
            } catch (java.security.NoSuchAlgorithmException e) {
                 e.printStackTrace();
            } catch (java.security.InvalidKeyException e) {
                 e.printStackTrace();
        public DESEncrypter(SecretKey key) {
            try {
                ecipher = Cipher.getInstance("DES");
                dcipher = Cipher.getInstance("DES");
                ecipher.init(Cipher.ENCRYPT_MODE, key);
                dcipher.init(Cipher.DECRYPT_MODE, key);
            } catch (javax.crypto.NoSuchPaddingException e) {
                 e.printStackTrace();
            } catch (java.security.NoSuchAlgorithmException e) {
                 e.printStackTrace();
            } catch (java.security.InvalidKeyException e) {
                 e.printStackTrace();
        public String encrypt(byte[] data) {
             return encrypt(new sun.misc.BASE64Encoder().encode(data), false);
        public byte[] decryptData(String s) throws IOException {
             String str = decrypt(s, false);
             return new sun.misc.BASE64Decoder().decodeBuffer(str);
        public String encrypt(String str, boolean useUTF8) {
            try {
                // Encode the string into bytes using utf-8
                byte[] utf8 = useUTF8 ? str.getBytes("UTF8") : str.getBytes();
                // Encrypt
                byte[] enc = ecipher.doFinal(utf8);
                // Encode bytes to base64 to get a string
                return new sun.misc.BASE64Encoder().encode(enc);
            } catch (javax.crypto.BadPaddingException e) {
                 e.printStackTrace();
            } catch (IllegalBlockSizeException e) {
                 e.printStackTrace();
            } catch (UnsupportedEncodingException e) {
                 e.printStackTrace();
            } catch (java.io.IOException e) {
                 e.printStackTrace();
            return null;
        public String decrypt(String str, boolean useUTF8) {
            try {
                // Decode base64 to get bytes
                byte[] dec = new sun.misc.BASE64Decoder().decodeBuffer(str);
                // Decrypt
                byte[] utf8 = dcipher.doFinal(dec);
                // Decode using utf-8
                return useUTF8 ? new String(utf8, "UTF8") : new String(utf8);
            } catch (javax.crypto.BadPaddingException e) {
                 e.printStackTrace();
            } catch (IllegalBlockSizeException e) {
                 e.printStackTrace();
            } catch (UnsupportedEncodingException e) {
                 e.printStackTrace();
            } catch (java.io.IOException e) {
                 e.printStackTrace();
            return null;
         // Here is an example that uses the class
         public static void main(String[] args) {
             try {
                 // Generate a temporary key. In practice, you would save this key.
                 // See also e464 Encrypting with DES Using a Pass Phrase.
                 SecretKey key = KeyGenerator.getInstance("DES").generateKey();
                 // Create encrypter/decrypter class
                 DESEncrypter encrypter = new DESEncrypter(key);
                 // Encrypt
                 String encrypted = encrypter.encrypt("Don't tell anybody!", true);
                 // Decrypt
                 String decrypted = encrypter.decrypt(encrypted, true);
             } catch (Exception e) {
                  e.printStackTrace();
              try {
                  // Create encrypter/decrypter class
                  DESEncrypter encrypter = new DESEncrypter("My Pass Phrase!");
                  // Encrypt
                  String encrypted = encrypter.encrypt("Don't tell anybody!", true);
                  // Decrypt
                  String decrypted = encrypter.decrypt(encrypted, true);
              } catch (Exception e) {
                   e.printStackTrace();
    }

  • How can i compare:  java.util.Date oracle.jbo.domain.Date?

    I have made a ViewObject wich contains a date column.
    I want to check if this date is smaller/greater than sysdate:
    i get following error:
    Error(45,24): method <(java.util.Date, oracle.jbo.domain.Date) not found in class Class4
    code:
    SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);
    // set up rules for daylight savings time
    pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
    pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
    // create a GregorianCalendar with the Pacific Daylight time zone
    // and the current date and time
    Calendar calendar = new GregorianCalendar(pdt);
    Date trialTime = new Date();
    calendar.setTime(trialTime);
    (VO_ULNRow)singleRow = null;
    while(vo.hasNext()){                                             // ViewObject vo;
    singleRow = (VO_ULNRow)vo.next();
    if(calendar.getTime() < singleRow.getEO_ULN_BORROWFROM()); //singleRow returns oracle.jbo.domain.Date
    etcetera
    how can i compare those 2?

    Hi,
    oracle.jbo.domain.Date has two methods which suit your needs
    longValue() which returns a long (though I'm not sure if returns a long comparable to the long returned by java.util.Date)
    and dateValue() which returns a java.util.Date
    I hope it helps,
    Giovanni

Maybe you are looking for

  • XML stream utf-8 encoding

    Hi folks, I'm trying to establish a CSTRING XML stream with utf-8 encoding. I've only managed to do this in XSTRING so far. If i use this coding, i get a binary output.   DATA: gt_result TYPE TABLE OF string,          l_result type string.   constant

  • Using Fault Message Type in BPM

    Hi, In my BPM Scenario, I am using a synchronous send step in which I am using a fault message type.For giving the container for the fault message in the Properties area of the send step, I want to define a container corresponding to the Fault messag

  • Safari did not offer an open in option for PDF file

    I went to Safari and went to a web based PDF file and selected the icon that brought up the list of options that did not include open in. Do I need to do something to get Safari to include that in the list? Thank you.

  • Pass thru authentication error message customization

    Dear All, I'm trying to customize the error messages displayed during the authentication failure. Users are authenticated against the AD i.e. pass thru authentication. I'm not able to customize the error messages. I have searched in WPmessgaes and RA

  • URGENT:  ORA-12154: TNS:could not resolve the connect identifier specified

    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 17001] Oracle Error code: 12154, message: ORA-12154: TNS:could not resolve the connect ide