+ 1
Can any one give an example for how and where to use API functions. Also an example program depicting its functionality.
2 Answers
+ 1
https://docs.oracle.com/javase/7/docs/api/ is a very useful resource.
*If you know how to use the Scanner class, Strings class, or Math class, those are all examples.
Graphics class
*This class allows you to render shapes, strings, and images.
Example program:
import java.awt.Graphics;
public class ExampleClass
{
public void drawRectangle(Graphics g)
{
//makes the rectangle green
g.setColor(Color.GREEN);
/*fills the rectangle green
*parameters: (x, y, width, height)
*/
g.fillRect (10, 10, 100, 100);
}
}
Hope this helps!
+ 1
In my previous answer, some examples of its pre-written functions include: setColor(), fillRect(), drawRect(), drawOval(), drawString(), drawImage(), and many more.
More information can be found on the website I provided on my previous answer.