import java.util.ArrayList;
import java.util.List;
import javax.swing.JEditorPane;
import javax.swing.JOptionPane;
public final class Main {
public static void main(String... args) throws Exception {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < 10; i++) {
for (int j = i; j < 10; j++) {
sb.append('*');
}
sb.append('\n');
}
System.out.println(sb);
sb = new StringBuffer(16);
String[] names = { "Peter", "David", "Susan", "Daniel", "Nancy" };
for (int i = 0; i < names.length; i++) {
sb.append(names[i]);
if (i < names.length - 2) {
sb.append(", ");
} else if (i < names.length - 1) {
sb.append(" and ");
}
}
System.out.println(sb);
class Product {
int id;
String name;
double price;
Product(int id, String name, double price) {
this.id = id;
this.name = name;
this.price = price;
}
int getId() {
return id;
}
String getName() {
return name;
}
double getPrice() {
return price;
}
}
List<Product> list = new ArrayList<Product>();
list.add(new Product(1, "Java Tutorial Book", 44.00));
list.add(new Product(2, "JavaServer Pages CD", 33.00));
list.add(new Product(3, "JavaServlet IDE", 0.0));
list.add(new Product(4, "Java Enterprise", 55.00));
list.add(new Product(5, "Java Collections", 44.00));
list.add(new Product(6, "Duke Picture Paper", 15.00));
sb = new StringBuffer("<html>\n");
sb.append("<head>\n");
sb.append(" <title>Products</title>\n");
sb.append("</head>\n");
sb.append("<body>\n");
sb.append("<table border=\"1\">\n");
sb.append(" <tr>\n");
sb.append(" <th>ID</th>\n");
sb.append(" <th>Name</th>\n");
sb.append(" <th>Price</th>\n");
sb.append(" </tr>\n");
for (Product p : list) {
sb.append(" <tr>\n");
sb.append(" <td>" + p.getId() + "</td>\n");
sb.append(" <td>" + p.getName() + "</td>\n");
sb.append(" <td>" + p.getPrice() + "</td>\n");
sb.append(" </tr>\n");
}
sb.append("</table>\n");
sb.append("</body>\n");
sb.append("</html>\n");
JEditorPane editor = new JEditorPane("text/html", sb.toString());
JOptionPane.showMessageDialog(null, editor, "Producst",
JOptionPane.PLAIN_MESSAGE);
System.out.println(sb);
}
}
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---