About Generic data type

LinkedList<Integer> i=new LinkedList();
How is it compile properly ?

Mrjavan wrote:
No everything is run properly.Yes, but the compiler gives you a warning about the third line:
$ javac Foo.java
Note: Foo.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
$ javac -Xlint:unchecked Foo.java
Foo.java:8: warning: [unchecked] unchecked conversion
found   : java.util.HashMap
required: java.util.HashMap<java.lang.Integer,java.lang.String>
    HashMap<Integer,String>hmap3=new HashMap();
                                 ^
1 warning
$To summarize:
In the first line, you declare the full parameterized type in the instanciation, but discard it because your variable only has the raw type. So you're doing useless work.
In the second line you declare the full parameterized type in both the variable declaration and the instanciation. That's the correct way. Now the compiler can check access to hmap2 for type correctness.
In the third line you declare the full parameterized type in the variable declaration, but use a raw type for the instanciation. Here the compiler gives you a warning that it can't check the assignment at runtime. Don't do that.
Note that at runtime all 3 will behave exactly the same, because of type erasure (google that term).

Similar Messages

  • Need Information about Generic Data sources

    Hi Experts,
    I need some information about Generic Data Sources in SD & MM applications.
    Can you please tell me on which Tables u have created Generic Data sources ?
    Just explain 2 scenarios.
    This is very helpful for my Interviews.
    Thanking you.

    HI,
    TBD10 --- Def., out of which IDOC fields a filter object is to be read
    BD59 maintains that table
    Rhea.
    Edited by: rhea on Nov 4, 2008 2:09 PM

  • About Number Data type

    Hi All,
    I have few issues with "Number" data type
    1) trying to convert string "0.0000007" to Number i am getting value with exponential (1e-7). This is only when we have more than 5 0's after decimal.
    2) If i try to do below calculation, i am not getting exact value:
    ex: 999999.999999+999999999999=1000000999999-999999999999 = 1000000(expected should be:999999.999999)
    0.3*6=1.79999998 (exact value: 1.8)
    Please let me know what might be the issue......
    Thanks in advance to all....

    That's standard behavior for floating point.  If you search the forum for
    past discussions of floating point and Number you'll see explanations why.
    To get displayable strings, use toPrecision or toFixed

  • About string data type

    Hi
    Maximum number of characters that a string data type accepts in Java.
    Thanks..

    The next may give a rough test.
    public static void main(String[] args) throws Exception{
    int factor= Integer.parseInt(args[0]);
    char[] data = new char[Integer.MAX_VALUE/factor];// note: integer division
    for(int k=0;k<data.length;k++)  data[k]=(char)0x30;
    String s=new String(data);
    System.out.println(Integer.toString(s.length()));
    }

  • Need a generic data type to hold any string

    Hi,
      I m trying to write a program which can log data from any table into a Trace Z table.
    I have used
    FIELD-SYMBOLS: <line>.
    to get the line of that table. But now I want to dynamically know what are the field names of this line structure and the data in it. And then write it as a string to the trace Z table
    form log_table_data tables rt_any_table
                        using rv_statement type string.
      data: v_line type string,
            v_char_line type char255.
      FIELD-SYMBOLS: <line>.
      loop at rt_table ASSIGNING <LINE>.
        v_char_line = <LINE>.                                 - Terminating at this statement
       ASSIGN <LINE> to v_line casting type string.
      endloop.
    endform.    
    Thanks for reading

    Hi,
    if you are interested in generic programming in ABAP then this [presentation|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b332e090-0201-0010-bdbd-b735e96fe0ae] is full of information. There is a class CL_ABAP_STRUCTDESCR with method GET_COMPONENTS. This method returns a list of components of table or structure. So you will be able to loop over every field in the table and convert each field into string.
    Cheers

  • I have a question about the data type static

    for any of you that read my last post for my assignment this is still the same thing but i have broke it down more, but i am getting an error and i am not for sure i understand why that is. I think i am confused on why i should, or could use a static?
    thanks again guys
    package wordstester;
    import javax.swing.JOptionPane;
    * @author christopher izatt
    public class WordsTester {
         * @param args the command line arguments
        public static void main(String[] args) {
                  // prompt the user to enter a string of their choice
          String wordChosen;
          wordChosen = JOptionPane.showInputDialog
              ("Please enter a word of your choice here");
          String middlePart;
          middlePart = Words.getMiddle(wordChosen);      <----- error nonstatic method can not be referenced in a static context
          System.out.println("At the middle of " + wordChosen + " is: "
                     + middlePart);
    package wordstester;
    * @author christopher izatt
        public class Words {
        private String wordChosen;
        public String Words(String letters) {
            wordChosen = letters;
            return wordChosen;
        public String getMiddle(String wordChosen) {
            int letters = wordChosen.length() / 2;
            int endindex = letters +1;
            return wordChosen.substring(letters, endindex);
       

    Try this.
    Imagine a blueprint from which houses are constructed. The blueprint indicates that each house will have a garage, a roof, a front door, etc. However, each house will have its own roof - be it a tar shingle roof or a cedar roof or maybe thatch - but that's another issue.
    Now, in the lower left corner of the blueprint, we find the architect's name and company logo. That logo is part of the blueprint - each house will NOT have its own discreet copy of that item. Instead, each house will share the one and only copy of that logo.
    That's what static members are. They are called "class variables" or "class methods" and are accessed through the class name instead of an object name.
    I hope that helps.

  • Explain about Data Types INT1, INT2, INT3, INT4 & NUMC

    could anyone explain about the data types and give examples.

    INT1: 1-byte integer between 0 and 255. The length is set to 3 places for this data type.
    INT2: 2-byte integer between -32767 and 32767. Fields of this type should only be used for length fields. These long fields are positioned immediately in front of a long field (type LCHR, LRAW). With INSERT or UPDATE on the long field, the database interface enters the length which was actually used in the length field. The length is set to 5 places for this data type.
    INT4: 4-byte integer between -2147483647 bis 2147483647. The length is set to 10 places for this data type.
    NUMC: Long character field in which only numbers can be entered. The length of this field is limited to a maximum of 255 places.
    Check this:
    http://help.sap.com/saphelp_nw70/helpdata/EN/cf/21f2e5446011d189700000e8322d00/frameset.htm
    Thanks...
    Shambhu

  • SQL Server 2014 Express, missing Data Type

    My problem is a simple one. When I create a new column and give it a Data Type, my options do not inlcude the "time" type. I found the documentation about available data types, and time is listed as one for SQL 2014. My desire is to have a data
    type that fits the HH:MM:SS format, excluding the date part that datetime offers. Any assistance is greatly appreciated.

    I did what you suggested, got this error:
    Msg 2715, Level 16, Sate 6, Line 1
    Column, parameter, or variable #6: Cannot find data type TIME.
    ALTER TABLE dbo.DataSchedule
    ALTER COLUMN StartClock TIME

  • As to the data type of the data type of the difference between two date type of datas

    Hi,
    I have a question about the data type of the difference between two date type of datas.
    There are two date type of datas as:
    SSHIPMENTS.RECEIVEDATETIME
    SSHIPMENTS.PROMISEDATETIME
    I try to use the following SQL Script in Oracle SQL*Plus as:
    SELECT CASE
    WHEN (SSHIPMENTS.RECEIVEDATETIME - SSHIPMENTS.PROMISEDATETIME) < '000 01:00:00.000' THEN 'OnTime'
    WHEN (SSHIPMENTS.RECEIVEDATETIME - SSHIPMENTS.PROMISEDATETIME) < '000 01:30:00.000' THEN '60-89 Minutes'
    ELSE '3+ Hours'
    END
    FROM SSHIPMENTS;
    The error message of "Invalid Number" for the '000 01:30:00.000' happens.
    I don't know if the data type of the interval is wrong.
    Many Thanks,
    Cathy

    SELECT CASE
    WHEN (to_char(SSHIPMENTS.RECEIVEDATETIME,'hhmiss') - to_char(SSHIPMENTS.PROMISEDATETIME,'hh24miss')) < '010000' THEN 'OnTime'
    WHEN (to_char(SSHIPMENTS.RECEIVEDATETIME,'hhmiss') - to_char(SSHIPMENTS.PROMISEDATETIME,'hh24miss'))< '000 01:30:00.000' THEN '60-89 Minutes'
    ELSE '3+ Hours'
    END
    FROM SSHIPMENTS;
    just try it out..

  • Is there a date data type in java???

    Hi guys!
    Is there a date data type in java???
    How to declare date data type variable?
    Your reply is greatly appreciated!
    -=samer=-

    RTFM
    there's about 8 date types, depending on what you want
    see
    java.util.Date
    java.util.Calendar
    GregorianCalendar
    SimpleDateFormat
    System.currentTimeMillis()

  • Plugout paramter problem with data types

    Hello everyone,
    i have a problem passing parameters between webdynpro components. i am trying to pass paramters with type which is not a generic data type but an rfc data type.
    i am getting an error does someone has an idea hot to do it or how to pass a record and not just one veriable
    thanks
    asher

    Hi,
    This can be done using external context mapping. Refer the tutorials section.
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/tutorial%20on%20server-side%20eventing%20-%2014.htm">https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/tutorial%20on%20server-side%20eventing%20-%2014.htm</a>
    Regards,
    Mahesh K.

  • Changing Chart Data Types

    Hi,
    I know this is a stupid question, but I can't figure for the life of me
    how to do it. I want to create a histogram, so I stick a waveform chart
    onto my VI. Fine, now I found the Moving Histogram PtByPt.vi example
    (ships with LabView 7). It creates a histogram and the data it sends to
    it is a cluster. This is very convenient because you just wrap your XY
    data up into a cluster and send it into the chart. Right now I can cut
    and paste the chart from this example, but if I didn't have the example
    I'd create a waveform chat, create my cluster with my xy data and pass
    it in. However, LabView complains about bad data types, because the
    default input data type is a 2D array of doubles. HOW DO I CHANGE THE
    DATA TYPE THE CHART ACCEPTS? I've been through every menu and property
    that I can think of, what's the secret? I've had this problem happen a
    couple of times and usually gotten around it by right clicking my lead
    and then picking to create something from a list and when it's created
    it's created with the right data type. However, it doesn't have that
    option in this situation. So what do I do? I've included a junk of my
    code for you to see if you want.
    Thanks for any help,
    Chris
    Attachments:
    Coincidence_v1.vi ‏53 KB

    You've got two different types of graphs. You have the XY graph wired to the cluster and you have a regular (not XY) graph. The regular graph does not accept the same type of input as the XY graph. It accepts a 1D  x array, 2D array (multichannel) a waveform data type, an array of waveforms (multichannels), and a cluster that contists of a y array, x0, and dx (essentially a waveform data type)

  • DSC with XML data type

    Hi,
    Can someone explain to me what the difference is between the xml data type and the Document data type in workbench? I would like to use the xml datatype in my DSC thinking it is most likely the best representation of an xml string. But I've heard that Document is more widely used and that it can represent an xml entity as well. Is this right?
    My ultimate goal is to write a DSC and use a type that represent an xml string. I would like the component.xml to have the type for my input variables to automatically be typed as "xml" or "document" (whatever the one i should be using is).
    I tried creating variables of both types ("xml' and "document", lower case d) and have those passed into my DSC for inspection. The object passed in are as follows:
    xml: org.apache.xerces.dom.DocumentImpl
    document: com.adobe.idp.Document
    But if I use any of those in my component.xml, workbench is typing my variables as "DocumentImpl" or "Document".
    Any ideas?
    Thanks in advance!
    Nic

    The xml variable (org.w3c.doc.Document) is a native xml data type. That means you can use xml functions and/or xPath expressions on the content of the variable.
    The document variable (com.adobe.idp.Document) is a more generic data type that can store any binary data. If you happen to store xml in that data type, you won't be able to run xml functions or xPath expression directly on the variable content since it's treated as binary data.
    If  you don't need to manipulate or access the content of the xml, then either data types will work. Otherwise, I would use the xml data type.
    In your component xml, make sure your xml data type is set to org.w3c.doc.Document and you'll see xml in Workbench.
    Jasmin

  • MDM Web Services - Data Types Schema

    Hi,
    I am trying to call MDM Web Services from PI as per our requirement. I need to build a scenario in PI for that. The Web Service documentation only talks about the data types and their strucuture but never said where they are available for download.
    Can any one of you help me in finding them for download or do we have to create them manually? Please refer to the link below for documentation.
    http://help.sap.com/saphelp_mdm550/helpdata/en/45/0068130b0c0487e10000000a155369/content.htm
    Thanks and Regards,
    VJ

    See the thread for information
    Configuration of MDM Web Service
    You can download the webservices from SAP support portal
    Points are welcome if it is helpful
    Koti Reddy

  • Weird int data type

    Hello everyone,
    When I used the toBinaryString method, I noticed smth which make me confused about int data type.
    For example:
    In the following codes, the output is 1100 weirdly.
    Whereas I knew that it must have been derived from 32 bits
    So what is the problem??
    int t = 12;     
    System.out.print(Integer.toBinaryString(t));

    what's unclear in the API about that ?
    [url=http://java.sun.com/j2se/1.5.0/docs/api/java/lang
    /Integer.html#toBinaryString(int)]toBinaryStringNoooo.. reading documentation is like cheating :)

Maybe you are looking for