Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • 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:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Warning: uses or overrides a deprecated API  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The warning I get is

IntegerNumberTester.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.


Could this warning be due to the fact my school uses a different version of Java with Windows 7 and I use the newest version with Windows 10?  Or is it something related to my code?

Here is my IntegerNumber class



and here is the tester that contains the warning:




Thank you for your help
 
Master Rancher
Posts: 3001
105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Jiub,

since (I think) Java 10 the constructor: 'Integer x = new Integer(5)' has been deprecated. Simply use: Integer x = 5; (or int x = 5; or var x = 5;)
 
Saloon Keeper
Posts: 2150
278
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jiub Anderson wrote:The warning I get is

IntegerNumberTester.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

Could this warning be due to the fact my school uses a different version of Java with Windows 7 and I use the newest version with Windows 10?  Or is it something related to my code?



To get more details, compile with the -Xlint:deprecation option.  For example (with different code):
 
Ron McLeod
Saloon Keeper
Posts: 2150
278
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jiub Anderson wrote:... and here is the tester that contains the warning:


Also, I don't see how you tester is actually testing your IntegerNumber class.
 
Marshal
Posts: 61721
193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, most of the constructors for the wrapper classes (which Cay Horstmann calls boxed primitive classes) have been deprecated because the valueOf() methods are likely to be more efficient in memory terms.
I can't see where you are using Thread#stop(), but that is a particularly dangerous thing to write. Maybe only PS used Thread#stop()
 
Ron McLeod
Saloon Keeper
Posts: 2150
278
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Related to this thread.
 
Jiub Anderson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ron McLeod wrote:

Jiub Anderson wrote:... and here is the tester that contains the warning:


Also, I don't see how you tester is actually testing your IntegerNumber class.




I did not finish writing the test class yet because I stopped at this warning.  I am testing to display a menu so user can select which method to test or to exit the program, and prompt the user to enter appropriate data (integer numbers) from the keyboard according to the selected option.
 
Piet Souris
Master Rancher
Posts: 3001
105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:(...) Maybe only PS used Thread#stop()


Me??
 
Ron McLeod
Saloon Keeper
Posts: 2150
278
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No - the comment was directed to me.  My example of compiling with  -Xlint:deprecation was using a different class (not the OP's), which has this deprecated call.

Sorry if I confused everyone.  
 
Campbell Ritchie
Marshal
Posts: 61721
193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Piet Souris wrote:. . . Me??

Only if I read the wrong name on the post. Sorry.
 
Piet Souris
Master Rancher
Posts: 3001
105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Sheriff
Posts: 5446
147
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jiub Anderson wrote:


I can't see any reason this couldn't just be
Those are horrible variable names, by the way.  First, don't start a variable name with an uppercase letter; use camelCase.  Second, don't use a variable name that differs from a keyword only by capitalization.  Third, a variable name should be self-documenting, like
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!