1. Add to 100 public class addsum {public static void main (string [] args) {INT i = 1, sum = 0; for (; i <101; i ) SUM = i; system.out.print Sum);}} 2, output diamond // Design a program, print diamond public class ling {public static void main (string [] args) {system.out.println ("Start printing diamond: / n"); int i = 1, j = 1, k = 0; int imax = 13; // Maximum line equal to 9 // First line equal to 1 requires the complement of the complement to equally equal to IMAX-1/2 for (; i <= imax; i = i 2) {system.out.print (""); for (j = 1; j <= ((iMAX-1) / 2-k); J ) system.out.print (""); for (J = 0; j 0; i = I-2) {system.out.print (""); k ; for (j = 1; j <= k; j ) system.out.print (""); for (j = 0; J
[Script] Write a simple applet // Capturing button Presses Import java.awt. *; Import java.applet. *; Public class button2new extend. *; Public class button2new {Button B1 = New Button ("Yeqiufeng"), B2 = New Button ("qfkx"); public void init () {b1.addactionListener (new b1 ()); b2.addactionListener (new b2 ()); add ( b1); add (b2);} class B1 implements ActionListener {. public void actionPerformed (ActionEvent e) {getAppletContext () showStatus ( "Button 1");}} class B2 implements ActionListener {public void actionPerformed (ActionEvent e) {getAppletContext () .ShowStatus ("Button 2");}}} Buttons written with new event models: //:button2new.java // Capturing Button Presses Import java.awt. *; import java.awt.event. * Import java.applet. *; Public class button2new extends applet {Button B1 = New Button ("Dun Dongya"), B2 = New Button ("Li Wei"); public void init () {b1.addactionListener (New B1 (NEW B1) )); B2.addActionListener (new b2 ()); add (b1); add (b2);} class b1 imports actionlistener {public void actionperfor med (ActionEvent e) {. getAppletContext () showStatus ( "Button 1");}} class B2 implements ActionListener {. public void actionPerformed (ActionEvent e) {getAppletContext () showStatus ( "Button 2");}}} successfully compiled After using Dreamweaver to add the class into the web page to adjust the appearance size to open the browser, you can use the browser. If the applet can read XML I will put my website ... Hey ... Today's practice is network programming first by the following examples. Network programming [script begin] import java.net. *; Public class whoami {public static void main (string [] args) throws exception {if (args.length! = 1) {System.err.Println ("Usage: "); System.exit (1);} inetaddress a = inetaddress.getByname (Args [0]); system.out.println (a);}} // call example java whoami yqf // Return YQF / 10.1 .1.20 [script end]