• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

generic program error  RSS feed

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


when 34 is passed ,then it will be converted into the Integer Object and passed to the constructor.So, when this code "u.byteValue()" ,which is in the display() method should be compiled properly,but it is throwing the error(because here 'u' is treated as a object)

error
-----
Compiling 1 source file to C:\deploy\pbnm\class\build\classes
C:\deploy\pbnm\class\src\GenericClassNine.java:20: cannot find symbol
symbol : method byteValue()
location: class java.lang.Object
System.out.println(u.byteValue());
1 error
BUILD FAILED (total time: 0 seconds)
 
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not an advanced question. Moving...
 
kumarth ravi
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It may not be the advanced question,but I want the answere,where can I get the answere

thanks
 
Ranch Hand
Posts: 2410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But look at it from the compiler's point of view. It has no way of knowing what class U will be.

The only thing the compiler knows for sure is that U is a subclass of Object.

So it can only let you call methods on the variable you that are defined in Object.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!