
Java
maximeete
这个作者很懒,什么都没留下…
展开
-
collection的使用
public static void main(String[] args) { Collection c = new ArrayList(); // 添加元素 c.add("孙悟空"); // 虽然集合里不能放基本类型的值,但Java支持自动装箱 c.add(6); System.out.println("c集合的元素个数为:" + c.size()); // 输出...原创 2018-08-04 15:18:28 · 1320 阅读 · 0 评论 -
实例
class ResultSetTableModel extends AbstractTableModel{ private ResultSet rs; private ResultSetMetaData rsmd; // 构造器,初始化rs和rsmd两个属性 public ResultSetTableModel(ResultSet aResultSet) { rs = aRe...转载 2018-09-16 20:57:46 · 113 阅读 · 0 评论 -
实例
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */package javaap...转载 2018-09-16 17:45:46 · 147 阅读 · 0 评论 -
实例
// 通过继承Thread类来创建线程类public class FirstThread extends Thread{ private int i ; // 重写run方法,run方法的方法体就是线程执行体 public void run() { for ( ; i < 100 ; i++ ) { // 当线程类继承Thread类时,直接使用this即可获取当...转载 2018-09-12 15:34:54 · 101 阅读 · 0 评论 -
StringBuilder应用举例
public class JavaApplication49 { /** * @param args the command line arguments */ public static void main(String[] args) { StringBuilder sb = new StringBuilder(); sb...原创 2018-09-06 14:12:21 · 480 阅读 · 0 评论 -
手绘图实例
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */package handdr...转载 2018-09-15 16:33:43 · 136 阅读 · 0 评论 -
实例
import java.sql.*;import java.util.*;import java.io.*;/** * Description: * <br/>网站: <a href="http://www.crazyit.org">疯狂Java联盟</a> * <br/>Copyright (C), 2001-2016, Yeeku...转载 2018-09-09 19:58:47 · 97 阅读 · 0 评论 -
实例
public void printResultSet(ResultSet rs)throws SQLException { //就是为了获得ResultSet的表头 ResultSetMetaData rsmd = rs.getMetaData(); for(int i = 0;i<rsmd.getColumnCou...转载 2018-09-09 17:40:09 · 115 阅读 · 0 评论 -
实例
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */package connec...转载 2018-09-09 16:15:18 · 99 阅读 · 0 评论 -
实例
import java.awt.*;import java.awt.datatransfer.*;/** * Description: * <br/>网站: <a href="http://www.crazyit.org">疯狂Java联盟</a> * <br/>Copyright (C), 2001-2016, Yeeku.H.Lee...转载 2018-09-12 22:17:34 · 94 阅读 · 0 评论 -
模板
/*为什么要有下面的这4个? 因为这4个参数是Class.forName和DriverManager.getConnection 的参数*/ static String driver; static String url; static String user; static String pass; //下面的方法就是为了获得参数 /...转载 2018-09-17 13:26:30 · 117 阅读 · 0 评论 -
Javaweb验证码项目
package com.jbben.jdbc.servlet;import javax.imageio.ImageIO;import javax.servlet.ServletException;import javax.servlet.annotation.WebServlet;import javax.servlet.http.Cookie;import javax.servle...原创 2019-02-15 14:02:59 · 224 阅读 · 0 评论 -
判断一个数字是否在1到12这12个数字之间
private int dealString(String s){ int a; try{ a = Integer.parseInt(s);} catch(Exception e){ e.printStackTrace(); return 1; } int[] intArray = {1,2,3,4,5,6,7,8,9,10,11,12}; for(int benInt...原创 2018-11-24 12:18:05 · 1762 阅读 · 0 评论 -
关于拖拽
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */package testex...原创 2018-11-19 21:16:01 · 141 阅读 · 0 评论 -
乒乓球实例
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */package pinbal...转载 2018-09-14 22:11:45 · 342 阅读 · 0 评论 -
实例
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */package testpr...转载 2018-09-18 22:41:18 · 120 阅读 · 0 评论 -
实例
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */package simple...转载 2018-09-13 16:25:15 · 122 阅读 · 0 评论 -
getProperty方法大全(转载)
System.out.println("java版本号:" + System.getProperty("java.version")); // java版本号System.out.println("Java提供商名称:" + System.getProperty("java.vendor")); // Java提供商名称System.out.println("Java提供商网站:" + Sys...转载 2018-09-18 19:16:02 · 2997 阅读 · 0 评论 -
实例
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */package testpr...转载 2018-09-17 19:44:38 · 133 阅读 · 0 评论 -
MySQL模板
//将下面的两个方法放到程序里面调用就可以了public class ConnectMysql { static String driver; static String url; static String user; static String pass; public void getParam(String param) throws Exc...原创 2018-09-09 14:07:02 · 297 阅读 · 0 评论 -
实例
public class ThrowTest{ public static void main(String[] args) { try { // 调用声明抛出Checked异常的方法,要么显式捕获该异常 // 要么在main方法中再次声明抛出 throwChecked(-3); } catch (Exception e) { System.ou...转载 2018-09-11 17:20:50 · 108 阅读 · 0 评论 -
事件、监听器接口和处理器之间的对应关系
原创 2018-08-07 18:56:38 · 1307 阅读 · 0 评论 -
事件监听的过程
public class EventQs{ private Frame f = new Frame("测试事件"); private Button ok = new Button("确定"); private TextField tf = new TextField(30); public void init() { // 注册事件监听器 ok.addActionListen...原创 2018-08-07 17:54:59 · 1130 阅读 · 0 评论 -
比较字符串
String cmd = e.getActionCommand(); ta.append("单击“" + cmd + "”菜单" + "\n"); if(cmd.equals("exit")){ System.exit(0); }用的是cmd.equals(Object anObject)...原创 2018-08-10 16:39:34 · 310 阅读 · 0 评论 -
关于dialog的一段实例代码
public class JavaApplication18 { Frame f = new Frame(); Button b1 = new Button("1"); Button b2 = new Button("2"); Dialog d1 = new Dialog(f,"d1",true); Dialog d2 = new Dialog(f,"d...原创 2018-08-09 22:10:56 · 182 阅读 · 0 评论 -
使用Lambda表达式遍历集合
public class CollectionEach{ public static void main(String[] args) { // 创建一个集合 Collection books = new HashSet(); books.add("轻量级Java EE企业应用实战"); books.add("疯狂Java讲义"); books.add("疯狂Andro...原创 2018-08-05 22:06:12 · 2527 阅读 · 2 评论 -
关于Lambda表达式表达ActionListener实例的时候的问题总结
b1.addActionListener(e -> d1.setVisible(true)); b1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ d1.setVisible(true); ...原创 2018-08-09 20:56:16 · 1543 阅读 · 0 评论 -
如何理解形参与实参
public class PrimitiveTransferTest{ public static void swap(int a , int b) { // 下面三行代码实现a、b变量的值交换。 // 定义一个临时变量来保存a变量的值 int tmp = a; // 把b的值赋给a a = b; // 把临时变量tmp的值赋给a b = tmp; Syst...原创 2018-08-04 20:53:56 · 562 阅读 · 0 评论 -
final关键字的使用
public class FinalVariableTest{ // 定义成员变量时指定默认值,合法。 final int a = 6; // 下面变量将在构造器或初始化块中分配初始值 final String str; final int c; final static double d; // 既没有指定默认值,又没有在初始化块、构造器中指定初始值, // 下面定义的ch实...原创 2018-08-04 17:18:13 · 135 阅读 · 0 评论 -
AWT常用组件
原创 2018-08-07 19:29:40 · 159 阅读 · 0 评论 -
事件适配器
原创 2018-08-07 20:11:07 · 388 阅读 · 0 评论 -
ResultSetMetaData的经典例子
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */package querye...转载 2018-09-07 20:37:10 · 283 阅读 · 0 评论 -
JDBC例子1
简单的从MySQL里读取值,显示到JTextField里/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in...原创 2018-08-29 17:18:21 · 137 阅读 · 0 评论 -
关于索引
转载 2018-08-29 12:13:28 · 152 阅读 · 0 评论 -
AutoBoxing和AutoUNBoxing
public class AutoBoxingUnboxing{ public static void main(String[] args) { // 直接把一个基本类型变量赋给Integer对象 Integer inObj = 5; // 直接把一个boolean类型变量赋给一个Object类型的变量 Object boolObj = true; // 直接把一个I...原创 2018-08-13 16:39:56 · 207 阅读 · 0 评论 -
关于swing的Border
这个例子搞通了,Border也就搞通了import javax.swing.*;import javax.swing.border.*;import java.awt.*;/** * Description: * <br/>网站: <a href="http://www.crazyit.org">疯狂Java联盟</a> * <br/&...原创 2018-08-13 15:15:38 · 515 阅读 · 0 评论 -
关于私有化构造器(private constructor)
For me the best explanation is in Effective Java book: Item 4: Enforce noninstantiability with a private constructor (See more)In Summary:Private constructor is due utility classes were not design...原创 2018-08-08 18:02:13 · 4517 阅读 · 0 评论 -
非常经典的swing入门代码
import java.awt.*;import java.awt.event.*;import javax.swing.*;/** * Description: * <br/>网站: <a href="http://www.crazyit.org">疯狂Java联盟</a> * <br/>Copyright (C), 2001-20...原创 2018-08-12 15:26:49 · 1542 阅读 · 2 评论 -
AWT菜单实例
import java.awt.*;import java.awt.event.*;/** * Description: * <br/>网站: <a href="http://www.crazyit.org">疯狂Java联盟</a> * <br/>Copyright (C), 2001-2016, Yeeku.H.Lee * <...原创 2018-08-07 22:15:13 · 486 阅读 · 0 评论 -
Html—Servlet—Service—Dao简单思路整理
#web项目思路整理(Html—Servlet—Service—Dao)##HTML请求触发页面加载时触发$(function(){Ajax请求})为指定元素加载事件时触发$(“元素选择器”).事件名称(function(){Ajax请求})请求格式$.请求方式(“请求路径”,{属性名:属性值...},function(data){回调函数},响应值类型)请求方式主要为g...转载 2019-02-10 21:03:20 · 544 阅读 · 0 评论