Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 25th, 2012, 12:39 PM
Falkin Falkin is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 4 Falkin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 29 sec
Reputation Power: 0
Homework - Recompile with -Xlint:deprecation for details

Full error: Example4.java uses or overrides a deprecated API. Recompile with -Xlint:deprecation for details.

I'm not sure why I'm getting this and I still have to do the rest of my printouts but wanted to figure this out first. I've also heard these are just warnings and don't worry about them but I'm not able to test my code to make sure everything is in working order.

import java.util.Date;

public class Example4 {
public static void main(String[] args) {

Buck buck1 = new Buck();


System.out.printf("Buck 1 %s years old");


Buck buck2 = new Buck("10/14/2001", 200.0, 68.0, 6, 2);


}
}

class Buck {


private Date bdate;
private double weight;
private double height;
private int points;
private int horns;


Buck() {
this.bdate = new Date("11/02/2000");
this.weight = 205.5;
this.height = 63.0;
this.points = 10;
this.horns = 2;
}

Buck(String bdateIn, double weightIn, double heightIn, int pointsIn, int hornsIn) {
this.bdate = new Date();
this.weight = weightIn;
this.height = heightIn;
this.points = pointsIn;
this.horns = hornsIn;
}

public Date getBdate() {
return bdate;
}
public double getWeight() {
return weight;
}
public double getHeight() {
return height;
}
public int getPoints() {
return points;
}
public int getHorns() {
return horns;
}


public int getAge() {
Date now = new Date();
int nowMonth = now.getMonth();
int nowYear = now.getYear();
int bdateMonth = bdate.getDate();
int bdateYear = bdate.getYear();

return (nowMonth >= bdateMonth ? nowYear - bdateYear:nowYear - bdateYear - 1);
}

double getmetricWeight(){
return weight / 2.2;
}
double getfeet(){
return height / 12;
}
}

Reply With Quote
  #2  
Old October 25th, 2012, 01:38 PM
bullet's Avatar
bullet bullet is offline
Java Junkie
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jan 2004
Location: Mobile, Alabama
Posts: 3,826 bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 6 Days 10 h 2 m 48 sec
Reputation Power: 1248
Send a message via ICQ to bullet Send a message via AIM to bullet Send a message via MSN to bullet
The Date class is an older class. Many of it's methods are deprecated.

Reply With Quote
  #3  
Old October 25th, 2012, 01:47 PM
Falkin Falkin is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 4 Falkin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 29 sec
Reputation Power: 0
Quote:
Originally Posted by bullet
The Date class is an older class. Many of it's methods are deprecated.


So I need to fix it with an updated class to fix this I'm assuming?

Reply With Quote
  #4  
Old October 25th, 2012, 01:49 PM
bullet's Avatar
bullet bullet is offline
Java Junkie
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jan 2004
Location: Mobile, Alabama
Posts: 3,826 bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 6 Days 10 h 2 m 48 sec
Reputation Power: 1248
Send a message via ICQ to bullet Send a message via AIM to bullet Send a message via MSN to bullet
Quote:
Originally Posted by Falkin
So I need to fix it with an updated class to fix this I'm assuming?


That's right. The recommended class is Calendar. For printing out, there is DateFormat.

Reply With Quote
  #5  
Old October 25th, 2012, 05:08 PM
Falkin Falkin is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 4 Falkin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 29 sec
Reputation Power: 0
Perfect...Thanks for your help

Reply With Quote
  #6  
Old October 25th, 2012, 06:06 PM
Falkin Falkin is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 4 Falkin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 29 sec
Reputation Power: 0
How would you rewrite the getAge...Ive tried every way I know of and I'm getting errors across the board

Reply With Quote
  #7  
Old October 26th, 2012, 08:14 AM
bullet's Avatar
bullet bullet is offline
Java Junkie
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jan 2004
Location: Mobile, Alabama
Posts: 3,826 bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level)bullet User rank is General 4th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 6 Days 10 h 2 m 48 sec
Reputation Power: 1248
Send a message via ICQ to bullet Send a message via AIM to bullet Send a message via MSN to bullet
Quote:
Originally Posted by Falkin
How would you rewrite the getAge...Ive tried every way I know of and I'm getting errors across the board


You can create an instance of a Calendar with the static method getInstance(). There are several predefined constants in the Calendar class. In particular, there is Calendar.MONTH, Calendar.DAY_OF_MONTH, etc. If you look at the docs for Calendar.java you will see all of them. You can get a particular piece of information with the get method.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Homework - Recompile with -Xlint:deprecation for details

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap