Map - why  not a part of collection interface

Pals,
Why Map is not a part of Collection interface. This was a question asked to be inteh interview.
I answered that it based on key value pairs thats y its not a part of collection interface. Dunno whether this is correct or not
Benji

And you could have scored some points if you casually mentioned that views of Map<K,V> do present collections:
Set< Map.Entry <K,V> > entrySet()
Set <K> keySet()
Collection <V> values()

Similar Messages

  • Why hashMap is not the part of collection framework

    why hashMap is not the part of collection framework ??
    why Map start its own new hierarchy??
    thanks

    A Map is not simply a collection of stuff, it is a mapping from stuff to stuff.
    It doesn't make any sense to "add stuff to a map", unless you tell it both a key and a value.
    It doesn't make any sense to ask "does this contain stuff", unless you tell it to look in its keys or in its values.
    Those (and similar) reason explain why a Map is not a Collection.
    Note that there are views of the keys and the values that do behave like Collections (for example you can take the keys() view of the Map and tell it to remove stuff from it and it will do what you'd expect). But the Map as a whole is not a Collection of stuff. It is a mapping of stuff.
    (I hereby declare "stuff" to be a technical term).

  • Why not static methods in an Interface

    why can't i make static methods part of an Interface?
    for example:
    public interface Names {
        public static String[] getNames(); // <--- "static" not allowed in an Interface.
    }what i want to say is:
    every class that implements the Names interface must have a static method, getNames() , that returns a raw array of Strings.
    why won't jave let me do this with an Interface?
    Edited by: kogose on Feb 4, 2009 5:47 PM

    this is my current solution:
    public interface Symbols {
        public String[] getSymbols();
    public class ETF implements Symbols {
        public String[] getSymbols() {
            return(ETF.symbols);
        private static String[] symbols =    { "DIG", "UYM", ...... }
    public class INDEXES implements Symbols {
        public String[] getSymbols() { return(symbols); }
        private static String[] symbols = { "^DZC", "^UTIL", "^GWI", .... }
    public class NYSE implements Symbols {
        public String[] getSymbols() {
            return(NYSE.symbols);
        private static String[] symbols =  { "GDL", "GDI", .... }
    }then to get the data:
    analyzer.analyze((new ETF()).getSymbols());
    analyzer.analyze((new INDEXES()).getSymbols());
    analyzer.analyze((new NYSE()).getSymbols());
    this looks like a hack to me?
    its weird that i create an object just to invoke one method and get static data.....
    is there an elegant way?

  • Internal error Occured mapping can not be opened - while opening interface

    Hi Gurus,
    I Am using ODI 11g to load data from Oracel to Oracel database using different schemas as a source to load facts.
    for the first time its loading sucessfully and when i try to open the same interface to see the mapping its showing the errror like *"Internam error Occured mapping can not be opened"*
    Tis is very urgent to resolve as per my project neeed.
    Please suggest steps : how to resolve the issue.
    Thanks in Advance.
    regards
    sri

    While the iTunes app is being updated, you are correct, it cannot be opened.
    This is true of all Apple apps on your Mac.
    iTunes is not very large compared to other apps.  Let it update, then open it.

  • Why not compile error on "incompatible interface cast"?

    simeple code here
    class IncompInterfaceTest {
    void doTest() {
    ClassB b = new ClassB();
    InterfaceA a = (InterfaceA)b;
    interface InterfaceA{}
    class ClassB{}
    javac issues "ClassCastException" on runtime rather than compile
    error.
    as i know incompatible type casting may be caught at runtime and
    compiler shows the error.
    but why compiler doesn't do it's job for interfaces? it's just so
    clear to be compile error to me.
    ps. in a case ClassB is final class, compiler issues a error.
    (a thread I started in google groups)
    http://groups.google.co.kr/group/comp.lang.java.programmer/browse_thread/thread/c9c12a8864672436?hl=ko#

    sun9h0st wrote:
    thanks for reply.
    I think i might know something wrong about class, object concept, so I wish you tell me more about it.
    As I though the code below means
    ClassB b = new ClassC();'b' can be an Object of ClassB as a subclass of ClassC.
    'b' IS an Object of ClassC.b is not an object.
    b is a variable that can point to an instance of ClassB or to an instance of any subclass of ClassB.
    >
    so
    b instanceof ClassB == true // as it can be
    b instanceof ClassC == true // as it is
    If b is not null, the first line will always be true.
    If b points to a ClassC or a subclass, the second one will be true.
    It means actual Object(something behind 'b' pointing, i don't know what i call it) is from ClassC to me. (somewhat like c pointer,
    'b' is a bowl that called Object and actuall instance is refered by 'b')No idea what you're saying here.
    if b IS an Object of ClassB
    shouldn't "b instanceof ClassC" is false?If we have C extends B, then...
    B b1 = new B();
    B b2 = new C();
    b1 instanceof B // true
    b1 instanceof C // false
    b2 instanceof B // true
    b2 instanceof C // true
    I Think compiler should be known that instance 'b' hold. No, it doesn't, and it's good that it doesn't, as it keeps the language simpler and more consistent.
    Also, b doesn't hold an instance. It holds a reference to an instance.

  • Why is the new map update not as good as the old one

    Why is the new map update not as good as the old one

    Why is the new map update not as good as the old one

  • Mesage mapping is not failing but interface mapping is failing

    Hi can any body help with the followin errro when i test  the interface  mapping  and surprisingly the message mapping is not failing
    Runtime exception occurred during execution of application mapping program com/sap/xi/tf/_MM_purchOrdChangeJR_to_salesOrdChangeR3_: com.sap.aii.utilxi.misc.api.BaseRuntimeException; RuntimeException in Message-Mapping transformation: Runtime exception during processing target field mapping /ORDERS05/IDOC/E1EDP01/E1EDP19/IDTNR. The message is: Exception:com.sap.aii.mappingtool.tf3.IllegalInstanceException: Too few values in first queue in function useOneAsMany. It must have the same number of contexts as second queue. in class com.sap.aii.mappingtool.flib3.NodeFunctions method useOneAsManycom.sap.aii.mappingtool.flib3.Plainer@d1221323c, ,
    can any body tell me the difference between message mapping interface mapping internally
    thanks andregards
    nelakonda

    Hi,
    > MM_purchOrdChangeJR_to_salesOrdChangeR3_: com.sap.aii.utilxi.misc.api.BaseRuntimeException; RuntimeException in Message-Mapping transformation: Runtime exception during processing target field
    1)  Select Message Mapping and  go for F7 and check is it correct  and test manually  by give values if possible  try to  paste the Pay load of the actual data  and test it  whether the Mapping  is Sucess
    2) Select the Interface Mapping  and Go for F7 and check  whether it  is correct. Check once  again  the Outbound / inbound Message Types
    3) Check Whether all the  necessary Objects  are Activated
    Regards
    Agasthuri Doss

  • Why not passing only one XML String parameter to Axis Web Service interface

    Hi,
    I am a newbie of axis and this is the first post in SUN site.
    I am writing a web service. I am considering this question after trying some examples in Axis:
    Why not defined parameters of our service interface (Service method.) as a XML String? -We can provide a XML Schema to Client, client fill all required information to a XML according to XML Schema. Seem that it is more straightforward than passing some complex objects.
    Your answer will be high appreciated!
    Thanks,
    -Hut

    Did you find a solution for that? Even im trying the same...

  • In SAP why CRM is a separate software, why it is not a part of R3 solution?

    Hi,
    My friends would like to know, in SAP why CRM is a separate software, why it is not a part of R3 solution?
    Help me to give a good answer to them.
    Regards,
    Manju

    hi,
    It is because purpose of both is different. CRM is used to increase business touch points to customer. ERP is used to run basic business processes. and purpose of crm is to bring customer close to you. It proivde various channels with which customer can intract. Marketing sales and services are basic block (pillar) of crm. For detils read documentation on sap.com
    Best Regards
    Pankaj Kumar

  • Why not use interfaces for constants?

    Hi,
    I have been getting conflicting views about why not use interfaces for constants?
    Can anyone shed some light on it?
    Piyush

    How so?
    If the constants are only used in a single classhow
    does it help to put them in a separate structute?
    (Ignoring the a type safe enumeration of course.)Well, mainly for readability. Suppose that you have a
    web application which has a servlet class
    "RedirectServlet", which takes a variable to redirect
    to a given JSP file. In the JSP files, you want to
    create forms which take this servlet as their action.
    You could of course put all these "redirect"
    constants in the RedirectServlet itself, but then
    it's kind of weird that you have to import a
    servlet in your jsp file to include these constants
    and to be able to write
    <form action="servlet/RedirectServlet?key=<%=
    RedirectServlet.HOMEPAGE %>> or so.
    Instead, you could create an interface called
    "RedirectConstants", and then your servlet
    RedirectServlet could implement this interface. Then
    your JSP can also access these constants via this
    interface.
    But then again, this is merely a matter of style, I
    fully agree that there is never a real _need_ to put
    constants in a separate structure if they're only used
    in a single class.Are you claiming that your example above is a single class?

  • 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.

  • Property or collection #comment was not found in the component interface

    Hi All,
    I am a Java developer trying to connect my java application to a peoplesoft webservice.
    I have been able to connect to the PS webservice and access "GET","FIND" methods successfully.
    But when i am trying to connect to the CREATE(insert) method, i get the following message text.
    <faultcode>SOAP-ENV:Client</faultcode>
    <faultstring>Component Interface API.</faultstring>
    <detail>
    <messages>
    <type>Error</type>
    <messagesetnumber>91</messagesetnumber>
    <messagenumber>74</messagenumber>
    <messagetext>Property or collection #comment was not found in the component interface at the given level.</messagetext>
    </messages>
    </detail>
    I dont have any access to peoplesoft or db logs, i started using SOAP UI to get the detail messages.
    Can anyone tell me what this message could be??
    Basically its an insert method which takes around 40 parameters out of which 2 are mandatory.
    The input that i send from my soap ui looks as follows
    +*<kcm:CASE_ID></kcm:CASE_ID>*+       
    <kcm:DISP_TMPL_ID>CRM_GOV</kcm:DISP_TMPL_ID>
    <!--Optional:-->
    <kcm:QUICK_CD>?</kcm:QUICK_CD>
    <!--Optional:-->
    <kcm:PROVIDER_GRP_NAME>City Manager Action</kcm:PROVIDER_GRP_NAME>
    <kcm:BUSINESS_UNIT>KCM01</kcm:BUSINESS_UNIT>
    <!--Optional:-->
    <kcm:PRODUCT_ID>?</kcm:PRODUCT_ID>
    When i dont send any parameter in case_id i get the above error and when i send +*<kcm:CASE_ID>?</kcm:CASE_ID>*+       
    i get a sql error
    <messages>
    <type>Error</type>
    <messagesetnumber>200</messagesetnumber>
    <messagenumber>0</messagenumber>
    <messagetext>SQL error. Stmt #: 650 Error Position: 123 Return: 1722 - ORA-01722: invalid number</messagetext>
    <explaintext/>
    </messages>
    <messages>
    <type>Error</type>
    <messagesetnumber>200</messagesetnumber>
    <messagenumber>0</messagenumber>
    <messagetext>SELECT /*+ FIRST_ROWS */ CASE_ID, DISP_TMPL_ID, BUSINESS_UNIT, RC_STATUS, RC_SUMMARY FROM PS_RC_ADD_CASE_VW WHERE CASE_ID=:1 AND DISP_TMPL_ID=:2 ORDER BY CASE_ID, DISP_TMPL_ID</messagetext>
    <explaintext/>
    </messages>
    <messages>
    <type>Error</type>
    <messagesetnumber>91</messagesetnumber>
    <messagenumber>48</messagenumber>
    <messagetext>Error accessing search record. {KCM_WEB_CASE_CI} (91,48)</messagetext>
    <explaintext>An error occurred while accessing the search record.</explaintext>
    </messages>
    <messages>
    <type>Error</type>
    <messagesetnumber>91</messagesetnumber>
    <messagenumber>61</messagenumber>
    <messagetext>Failed to create the Component Interface</messagetext>
    </messages>
    I am not understanding how do i debug this further as its very difficult for me to get any peoplesoft logs or db logs.
    Any help will be appreciated.
    Thanks
    Ash
    Edited by: ash81 on Jun 14, 2010 1:24 PM

    This will be very hard to troubleshoot without access to PeopleSoft.
    Ideally, the best way to test it would be replicate the steps you are performing in your code through the component interface/web service, and then on the actual PeopleSoft component to see if you get the same error.
    The second case where you haven't put in the parameters, make sure you clear out the ? marks and leave the value empty if you don't need to specify it.
    E.g.
    Instead of <kcm:QUICK_CD>?</kcm:QUICK_CD>
    Use: <kcm:QUICK_CD></kcm:QUICK_CD>
    I generally work backwards from soapUI -- look at the soapUI error, then test through the component interface tester in PeopleSoft application designer, then if required test in PeopleSoft.

  • Why Collection interface declares equals() and hashCode() method

    When I went through the source code of Collection interface, I found equals() and hashCode() are declared? Why? If a class implements this interface, it will inherit these two method from Object, and we can true to override them.

    It's probably so that they can provide the documentation that you see there.

  • Why not add google chrome as a part of safari?

    Why not add google chrome as a part of safari?

    Since we are all just users here, you might want to direct your question to Apple via the attached link:
    http://www.apple.com/feedback/ipad.html

  • Map is not laoding street names why???

    map is not laoding street names why???

    The guy we hired to do maps there got lost & we haven't heard from him in months. Currently looking for someone else, so have patience....

Maybe you are looking for

  • Videos don't play smoothly on brand new top spec MacBook Pro

    Hi, I've just bought a brand new MacBook Pro 15 inch retina, upgraded to 2.7ghz processor. Video content on YouTube and Vimeo is juddering and skipping worse than it does on my 2009 MacBook Pro. It's not smooth at all. I've had the computer a couple

  • Anyone seeing pastes as html instead of plain or formatted text?

    I am being assisted by Microsoft here - but thought this may be a conflict problem so am posting here: Has anyone experienced this:?: In MS Word (2008 or 2011) when copying text in a document and then pasting, the pasted text is all html - blue and u

  • Why is the https protocol used on all pages of arch wiki & forums ?

    I don't know if it's true, but I heard that the https protocol requires more server resources than http, maybe because the server has to encrypt the data before sending it to the client. Therefore, as far as I know, https is usually used only on web

  • Safari silently quits when clicking on a link

    Safari on my mac has developed a tendency to quit abruptly - no "unexpectedly quit" message comes up, it just quits - when clicking on a link. This is not specific to one particular type of link, though it seems to happen more often when the link is

  • Changing scroll bars to buttons

    Hello all, I use Macromedia Dreamweaver Mac for my wepage editing, I was wondering if anyone knows any helpful tutorials or instructions on how to replace the ugly grey scroll bars in your frames with arrow buttons or the like. Thanks much !!