Results 1 to 3 of 3
  1. #1
    nakkim is offline Member
    Join Date
    Feb 2014
    Posts
    4
    Rep Power
    0

    Default Am I understanding classes correctly?

    So If I import static java.lang.Math.*

    This means that I can use the math class in my new class, so I imported "Math" from Java classes, and these are in the libaries with other thousands of premade classes that I am able to use from?

    So those imports are similar to the functions of inheritance and implements

    Questions are:
    Who make these premade java classes?
    Last edited by nakkim; 02-13-2014 at 05:24 AM. Reason: nvm

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,602
    Rep Power
    5

    Default Re: Am I understanding classes correctly?

    Quote Originally Posted by nakkim View Post
    So those imports are similar to the functions of inheritance and implements
    No. The imports just make it easier for you to use the classes without specifying
    the fully qualified class name. It has nothing to do with inheritance.
    Quote Originally Posted by nakkim View Post
    Who make these premade java classes?
    The implementers of the JDK. If you have the source code you will usually see
    their names in the comments along with the date of development.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    kaydell2 is offline Senior Member
    Join Date
    Dec 2012
    Posts
    106
    Rep Power
    0

    Default Re: Am I understanding classes correctly?

    So If I import static java.lang.Math.*

    This means that I can use the math class in my new class, so I imported "Math" from Java classes, and these are in the libaries with other thousands of premade classes that I am able to use from?
    A static import allows you to use the static variables and the static methods of the Math class without specifying "Math." I prefer to use the prefix "Math." so that I know where things are coming from.

    So those imports are similar to the functions of inheritance...
    No, static imports are merely a convenience and don't have anything to do with inheritance

    ...and implements
    No, static imports don't have anything to do with implementing interfaces either.

    Questions are:
    Who make these premade java classes?
    Oracle, the developers of Java, wrote the Math class and many other classes that come with Java. These classes are called the Java Application Programming Interfaces (Java API) which is mostly written in Java. Nowadays (since Java 6+) you can get the source code for the Java API and see exactly what is there.

    Some things are imported automatically, such as the package:

    java.lang

    which are things that are half Java language and half Java API, such as the String class.

Similar Threads

  1. Understanding CMD and Classes?
    By fahman_khan75@yahoo.com in forum New To Java
    Replies: 3
    Last Post: 01-23-2014, 12:52 PM
  2. Problem with understanding the use of classes
    By Robomano in forum New To Java
    Replies: 4
    Last Post: 12-10-2012, 11:45 AM
  3. Replies: 2
    Last Post: 01-22-2012, 11:50 PM
  4. difficulty understanding writing classes
    By elecleoalune in forum New To Java
    Replies: 11
    Last Post: 04-18-2011, 03:06 PM
  5. Am I understanding this correctly?
    By phixion in forum New To Java
    Replies: 9
    Last Post: 01-27-2011, 05:13 AM

Posting Permissions

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