I'm a beginner at Java Programming. I have the experience that I used DX library for before in C++. The DX library worked with simple functions, but the library of the JAVA does not work with functions.
How can I understand Java Class libraries?
I'm a beginner at Java Programming. I have the experience that I used DX library for before in C++. The DX library worked with simple functions, but the library of the JAVA does not work with functions.
How can I understand Java Class libraries?
I highly suggest going through the Sun Java Tutorial, and then asking specific questions about specific problems based upon that. The Java libraries are actually fairly simple to work with, but there are a lot of them.
Are you using an IDE to get started? They are strongly recommended for beginning Java programmers.
Let us start with a simple example
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!"); // Display the string.
}
}
This uses the "out" member of java.lang.System; which is a PrintStream; it uses the PrintStream
type's println
method to print a string with a following line-feed.
It sounds like your usage of C++ has been fairly limited and that you have not truly taken advantage of the OOP features of the C++ langauge, given this question. The Java API is a class library. There are no free-standing functions in Java (unless you count static functions as free-standing functions). Please familiarize yourself with OOP and the Java language, and then come back with specific API questions.
Not functions, but methods of Objects. That's a big difference, and the key to OO.
Simple example:
String x = new String("abcdef");
String y = x.substring(2);
Note the idea you start by getting a reference to an object of a particular type, here x is a String.
You then can ask x to do lots of different things, such extract substrings. The full set of what you can do is documented in the String class.
So a way to approach things is to say
As has been pointed out, the online tutorials will help. Take the time to work through some.
IDEs (Ecplise is free for example) will give you "help" offering menus of availble methods when you have an object.
Very often for each new thing you want to do there are useful code snippets.