How to combine different APIs in meaningful ways? [message #1768516] |
Wed, 19 July 2017 15:52 |
RajibKumar Bandopadhyay Messages: 58 Registered: July 2014 |
Member |
|
|
Suppose that I have these four APIs within the http://docs.oracle.com/javase/8/docs/api/index.html
- PrintStream java.lang.System.out
- void java.io.PrintStream.println(String x)
- java.util.Arrays
- String java.util.Arrays.toString(Object[] a)
What I mean is that, if I come across these above four API definitions/descriptions independently, I wouldn't be in a position to know that they could be weaved together into a meaningful form:System.out.println(Arrays.toString(args)); unless I have specific examples.
This is what I need to know:
How to be able to weave together terms from the list: http://docs.oracle.com/javase/8/docs/api/index.html into code lines that work in a meaningful way?
I have been given two different directions in CodeRanch:
- How you can do things quickly and efficiently is something that you learn by practising,
- you need to look method declaration signature, which kind of parameters and their types method accepts as arguments
I have copied the suggestions verbatim, as they were originally received. I hope to collect diverse unique ideas, carefully weigh them and select apparently the currently most-suited one.
I believe that there are outstanding programmers who could provide me with the needed insight. I'm willing to wait for such an insight.
[Updated on: Sat, 22 July 2017 04:30] Report message to a moderator
|
|
|
|
|
|
|
Re: How to combine separate APIs in meaningful ways? [message #1770972 is a reply to message #1768555] |
Sun, 20 August 2017 09:02 |
RajibKumar Bandopadhyay Messages: 58 Registered: July 2014 |
Member |
|
|
Posted for someone looking for a similar answer:
You don't need to look at the link: How to link separate informations on the APIs available in the Javadoc or API Web index? which is similar to the above post.
Since the first posting and the queries elsewhere, I have learnt somewhat to improvise. You could take a look at the improvised code below, seed taken from Learn Java in a Weekend by Joseph Russell. From the basic time based code there, I finally found and then used nanoTime by searching through the API index, via currentTimeMillis().
I find that such discovery is about hunches, intuitions and calculated leaps, to arrive at the API(s) one requires, but the API index doesn't help in any way. It could have, had there been a inter- and hyper- linked database application, like the Windows Help Application. But there is none!
The codes is here:
//see how fast the computer can count to a million
System.out.println("\nCounting to one million...");
System.out.println("Ready... GO...");
// start = System.currentTimeMillis(); // get starting time
start = System.nanoTime();
for (double j = 1; j <= 1000000; j++) {
//no loop body
// Time.counter;
// end = System.currentTimeMillis(); // get ending time
end = System.nanoTime();
}
System.out.println("Done!" + "in " + (end - start) + " nanosec, or "
+ ((end - start)/1000000000) + "." + ((end - start)%1000000000) + " Sec");
[Updated on: Sat, 26 August 2017 03:31] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.08362 seconds