Results 1 to 3 of 3

Thread: Multiple generic types

  1. #1
    Harald Uwe is offline Junior Member
    Join Date
    Sep 2009
    Posts
    28
    Rep Power
    0

    Default Multiple generic types

    Hi. I am learning JAVA programming language. I created a generic class:
    Here is the code for it
    Code:
    Public interface myclass <T,U>
    {
      ...
    }
    With that, I can instantiate objects like this:
    Code:
    mylcass <String, boolean> a = new myclass <String,boolean>();
    What I do here please guide me:
    Code:
    myclass <String> a= new myclass <String>();
    Is there a way to make an optional type with generics? Any help would be highly appreciated.

  2. #2
    Benjamin Lutz is offline Junior Member
    Join Date
    Sep 2009
    Posts
    24
    Rep Power
    0

    Default

    I think there is an error in the code and you can change it in this way,
    Code:
    myclass <String, Object> a = new myclass <String,Object>();
    Hope this will resolve your problem.

  3. #3
    Egon Poldi is offline Junior Member
    Join Date
    Sep 2009
    Posts
    26
    Rep Power
    0

    Default

    Try to understand following code which is helpful for you .Check out this
    Code:
    myclass <String,Boolean> a = new myclass <String,Boolean>();
    in place of use the following in your code
    Code:
    myclass <String, boolean> a = new myclass <String,boolean>();
    I hope you know the differences between the two.

Similar Threads

  1. Generic.dx! osw Virus Issue
    By HallMiller in forum General Internet Terms
    Replies: 2
    Last Post: 03-17-2010, 01:43 PM
  2. Generic Types in C#
    By Brownchris in forum Programming
    Replies: 2
    Last Post: 02-09-2010, 03:55 PM
  3. Generic PWS.y! brn deletion difficulty
    By ScottWright in forum Networking Jargons
    Replies: 1
    Last Post: 01-22-2010, 02:05 PM
  4. How to Get Rid of a Generic Trojan
    By EvansMitchell in forum Software Jargons
    Replies: 0
    Last Post: 01-02-2010, 02:39 PM
  5. Generic 1GB DDR533 Memory
    By iankloap in forum Motherboards & Memory
    Replies: 0
    Last Post: 07-25-2008, 12:58 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48