Get Foreground Color Of an Applet Window
import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
public class GetForgroundColorExample extends
Applet
{
public void paint(Graphics g)
{
Color
c = getForeground();
g.drawString(c.toString(),50,50);
}
}
Replace an element at specified index of Java
ArrayList
import
java.util.ArrayList;
public class
ReplaceElementAtSpecifiedIndexArrayListExample
{
public static void
main(String[] args)
{
ArrayList arrayList =
new ArrayList();
arrayList.add("1");
arrayList.add("2");
arrayList.add("3");
arrayList.set(1,"REPLACED
ELEMENT");
System.out.println("ArrayList
contains...");
for(int index=0; index
< arrayList.size(); index++)
System.out.println(arrayList.get(index));
}
Replace an element at specified index of Java
ArrayList
import
java.util.ArrayList;
public class
ReplaceElementAtSpecifiedIndexArrayListExample
{
public static void
main(String[] args)
{
ArrayList arrayList =
new ArrayList();
arrayList.add("1");
arrayList.add("2");
arrayList.add("3");
arrayList.set(1,"REPLACED
ELEMENT");
System.out.println("ArrayList
contains...");
for(int index=0; index
< arrayList.size(); index++)
System.out.println(arrayList.get(index));
}
}
Create Custom Color Using HSB
import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
public class CreateCustomColorUsingHSB extends
Applet
{
public void paint(Graphics g)
{
Color customColor =
Color.getHSBColor(0.9f,0.5f,0.8f);
this.setForeground(customColor);
g.drawString("This is a custom HSB
color", 10, 50);
}
}
Convert short primitive to Short object
public class shortToShortExample
{
public static void
main(String[] args)
{
short s = 10;
Short sObj = new
Short(s);
System.out.println(sObj);
}
}
No comments:
Post a Comment