Win a copy of Java XML & JSON this week in the XML and Related Technologies 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
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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: 3080
108
  • 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: 2329
293
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: 2329
293
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: 62803
203
  • 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: 2329
293
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: 3080
108
  • 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: 2329
293
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: 62803
203
  • 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: 3080
108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Sheriff
Posts: 5662
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
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!