the very first program
hello world in java
public class HelloWorld { public static void main(String[]args) { System.out.println("Hello World!"); } }
Bookmark It
|
|||||
|
the very first program hello world in java public class HelloWorld { public static void main(String[]args) { System.out.println("Hello World!"); } } Bookmark It ask the user for their name and then display it user interaction import javax.swing.*; public class EnterName { public static void main(String[]args) { String name; name = JOptionPane.showInputDialog("Type in your name: "); System.out.println(name); System.exit(0); } } Bookmark It a first applet a first applet /* applet source code compile as normal */ import java.applet.*; import java.awt.*; public class HelloWorld extends Applet { public void paint(Graphics g) { g.drawString("Hello world" Bookmark It an example which shows if else control structures if / else grades example import javax.swing.*; public class grades { public static void main(String[] args) { String result; int testscore = 0; char grade; result = JOptionPane.showInputDialog("Type in your grade: "); testscore = Integer.parseInt(result); if (testscore >= 90) { grade = ‘A’; } else if [...] another beep example another beep example import java.awt.*; public class beep { public static void main(String args[]) { Toolkit.getDefaultToolkit().beep(); } } Bookmark It |
|||||
|
Copyright © 2012 Programmingsite : source code - All Rights Reserved |
|||||