Results 1 to 4 of 4
  1. #1
    ravian is offline Senior Member
    Join Date
    Nov 2007
    Posts
    115
    Rep Power
    0

    Default Using Deprecated Methods

    I understand that using deprecated methods are the methods that won’t be supported in the higher versions of Java. So, if I use it in my current Java, is it perfectly OK? I mean is it a bad practice or what?
    Example: methods of Date class.

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default deprecated methods

    if I use it in my current Java, is it perfectly OK?
    You will get compiler warnings and the app will run okay. Java tries to backward–compatible up until j2se 1.5. Generics was a big change.
    I mean is it a bad practice or what
    Inelegant. When you get a compiler warning look up the method in the javadocs. The Method Summary and Method Detail sections will say that the method has been deprecated and tell what method to use in its place. This is the general paractice. For example, older apps used to use the show method to show a JFrame. Compiling code that uses the show method gives a compiler warning:
    Java Code:
    C:\jexp>javac stf.java
    Note: stf.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    
    C:\jexp>javac -Xlint:deprecation stf.java
    stf.java:73: warning: [deprecation] show() in java.awt.Window has been deprecate
    d
            f.show();
             ^
    1 warning
    
    C:\jexp>java STF
    
    C:\jexp>
    You can run the app okay as–is if you like. If you want to get the details recompile as indicated. Looking in the JFrame class api for the show method you find it in the section "Methods inherited from class java.awt.Window". Follow the link to see that it has been replaced by setVisible as of j2se 1.5

  3. #3
    staykovmarin is offline Senior Member
    Join Date
    Nov 2007
    Location
    Newport, WA
    Posts
    141
    Rep Power
    0

    Default

    Generally that is not a good idea however. Deprecated means that they don't have be supported in later versions of java, therefore killing portability.

    Also i have found that it is a better idea to use the methods that are provided to replace them. They are deprecated for a reason.

  4. #4
    ravian is offline Senior Member
    Join Date
    Nov 2007
    Posts
    115
    Rep Power
    0

Similar Threads

  1. getYear deprecated method
    By ravian in forum New To Java
    Replies: 5
    Last Post: 01-05-2011, 09:50 AM
  2. I need help with a deprecated program
    By mikau in forum New To Java
    Replies: 0
    Last Post: 02-13-2008, 10:34 AM
  3. methods
    By Zensai in forum New To Java
    Replies: 10
    Last Post: 12-03-2007, 06:31 AM
  4. Methods
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-01-2007, 09:49 PM
  5. method size is deprecated
    By oregon in forum New To Java
    Replies: 4
    Last Post: 08-05-2007, 06:59 PM

Posting Permissions

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