Author Topic: Java Question  (Read 742 times)

Garrett

  • Autococker
  • Posts: 1372
Java Question
« on: January 28, 2008, 07:06:37 PM »
I just started my Java class today and my teacher is really learning the curriculum with us so he had a hard time explaining my question to me.
I know that C++ needs the use of libraries to be able to compile any program, but after learning the basics of Java, I am kind of confused.  I know the basic process of how my Java code is compiled into machine code but there was a term that I never heard of, 'API'.
My question is does Java use libraries and what does an API do?  The definition I found on the webopedia was to wordy and didn't really make much sense.

Eiii

  • Autococker
  • Posts: 4595
Re: Java Question
« Reply #1 on: January 28, 2008, 08:14:09 PM »
Java uses 'namespaces', which are, as I understand them, really big static objects with lots of stuff in them that you can access. And an API is just a wrapper to allow you easier access/interaction to/with lower-level functions, but don't quote me on that.

sk89q

  • Global Moderator
  • Autococker
  • Posts: 1049
Re: Java Question
« Reply #2 on: January 28, 2008, 10:16:46 PM »
The libraries that C++ uses are low-level, but every language has libraries of some sort (it's just code that can be re-used). However, you don't need to worry about compiling against certain libraries like in C++ because Java simplifies everything a lot. That and Java doesn't compile to machine code until it is run through the JVM.

API stands for Application Programming Interface. It is the front-end that your code interacts with to control whatever is the backend. For example, say you have a program that controls a photo of Eiii's face that is stored in memory. Without an API, you would have to fiddle the memory directly to change his face. However, if it comes with an interface, you can use that instead. The "interface" could have functions like makeBigger() or makeLookLikeJitspoe() or changePixelColor(x, y, color).

Namespaces just allow for organization. Instead of having all the objects in the main scope, you can put it into categories called namespaces. System.IO.LineBuffer versus LineBuffer. Without namespaces, you would have a problem if two independent groups wanted to name a class the same name.