Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to use api

 
laks subramanian
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can somebody illustrate the use of API and how one will use it.
thanks in advance
 
Sigfred Zamo
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are referring to the Sun�s API doc, go to (J2SE 1.4):
http://java.sun.com/j2se/1.4/docs/api/index.html
There you have all the classes and interfaces in alphabetical order, you can access them along the the frames placed at the left side.
�Is this the info u need?
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well - there is some confusion in terminology here. We often refer to the Sun documentation of the API as the API. That is used to read up on what stuff is available from Sun to be used by us folks out here.
Of course TECHNICALLY the API is the code itself. It is that portion of the code that is public, and therefore available to be used by other classes. It is the fields and methods that OUR classes can use to interact with THEIR classes. Their code also contains encapsulated stuff that they do NOT provide access to, so that portion of the code is not part of the "interface" to their code.
 
laks subramanian
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks cindy and sigfred, but an example would be highly appreciated(if possible).
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An example of WHAT?
You just READ the thing, and then you can use anything of the methods or Fields that it talks about.
For instance if you go to the Integer class (a wrapper class for ints), it shows you all of the methods that Integer types can use.
One of those methods is a static method named parseInt(String s).

parseInt
public static int parseInt(String s)
throws NumberFormatException
Parses the string argument as a signed decimal integer. The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign '-' ('\u002D') to indicate a negative value. The resulting integer value is returned, exactly as if the argument and the radix 10 were given as arguments to the parseInt(java.lang.String, int) method.
Parameters:
s - a String containing the int representation to be parsed
Returns:
the integer value represented by the argument in decimal.
Throws:
NumberFormatException - if the string does not contain a parsable integer.


After reading that I know that I can do
String myString = "10";
int i = Integer.parseInt(myString);
and i now holds the int value 10.
[ April 16, 2002: Message edited by: Cindy Glass ]
 
laks subramanian
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Cindy, I got it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic