
JavaSE
文章平均质量分 53
种子之家
程序人生,人生程序
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
在某段时间内,随机产生一个时间,包括时分秒
package com.bjpowernode.hibernate;import java.text.SimpleDateFormat;import java.util.Date;import junit.framework.TestCase;public class RondomDateTest extends TestCase{ public void testRondom原创 2016-06-24 16:48:02 · 10352 阅读 · 0 评论 -
死锁
package com.cavaness.quartzbook.chapter3;/** * 死锁问题 * * 开始两个线程,一个线程调用同步代码块,另外一个调用同步函数 * */public class Test { public static void main(String[] args) throws InterruptedException { TestThrea原创 2012-08-17 19:51:21 · 401 阅读 · 0 评论 -
同步代码块和同步函数之间同步
package com.cavaness.quartzbook.chapter3;/** * 开始两个线程,一个线程调用同步代码块,另外一个调用同步函数,同步代码块和同步函数的代码一模一样,所以 * 同步代码块和同步函数两者之间也必须同步,即是不能存在一个线程调用同步代码块的同时另外一个线程调用同步函数 * @author Kevin * */public class Test {原创 2012-08-17 19:29:31 · 2390 阅读 · 0 评论 -
用table显示n条记录,每3行换一次颜色,即1,2,3用红色字体,4,5,6用绿色字体,7,8,9用红颜色字体。
window.onload=function() { var tbl = document.getElementById("tbl"); var rows = tbl.getElementsByTagName("tr"); for(i=0;i<rows.length;i++) {原创 2012-08-18 15:41:10 · 7896 阅读 · 0 评论 -
单例2
package com.cavaness.quartzbook.chapter3;public class Test { private static Test instance = null; public static synchronized Test getInstance() { // 这个方法比上面有所改进,不用每次都进行生成对象,只是第一次 // 使用时生原创 2012-08-18 15:20:19 · 465 阅读 · 0 评论 -
单例
package com.cavaness.quartzbook.chapter3;public class Test { private static Test test = new Test(); private Test() { } public static Test getInstance() { return test; } public void meth原创 2012-08-18 15:14:16 · 372 阅读 · 0 评论 -
Set3
package com.cavaness.quartzbook.chapter3;import java.util.Collection;import java.util.HashSet;public class Point { private int x; private int y; public Point(int x, int y) { super(); this原创 2012-08-18 11:18:04 · 537 阅读 · 0 评论 -
Set2
package com.cavaness.quartzbook.chapter3;import java.util.Collection;import java.util.HashSet;public class Point { private int x; private int y; public Point(int x, int y) { super(); this原创 2012-08-18 11:03:22 · 552 阅读 · 0 评论 -
Set
package com.cavaness.quartzbook.chapter3;import java.util.Collection;import java.util.HashSet;public class Point { private int x; private int y; public Point(int x, int y) { super(); this原创 2012-08-18 10:59:52 · 316 阅读 · 0 评论 -
HashMap和Hashtable
package com.cavaness.quartzbook.chapter3;import java.util.HashMap;import java.util.Hashtable;public class Test { public static void main(String[] args) { String string = null; HashMap hash =原创 2012-08-18 10:17:39 · 355 阅读 · 0 评论 -
线程的stop
package com.cavaness.quartzbook.chapter3;/** * 线程通信问题 */public class Test { public static void main(String[] args) { TestThread testThead = new TestThread(); new Thread(testThead).start();原创 2012-08-18 09:17:45 · 429 阅读 · 0 评论 -
进程间通信
package com.cavaness.quartzbook.chapter3;public class Data { private String name = "unknown"; private String sex = "unknown"; private boolean bFull = false; public String getName() { return n原创 2012-08-18 08:40:06 · 655 阅读 · 0 评论 -
合并子线程
package com.cavaness.quartzbook.chapter3;public class Test { public static void main(String[] args) throws InterruptedException { Thread thread = new TestThread(); thread.start(); int index =原创 2012-08-17 09:41:59 · 591 阅读 · 0 评论 -
同步代码块
package com.cavaness.quartzbook.chapter3;/** * 四个线程在卖100张票 * @author Kevin * */public class Test { public static void main(String[] args) { TestThread testThread = new TestThread(); new Th原创 2012-08-17 11:14:28 · 455 阅读 · 0 评论 -
同步函数
package com.cavaness.quartzbook.chapter3;/** * 四个线程在卖100张票 * @author Kevin * */public class Test { public static void main(String[] args) { TestThread testThread = new TestThread(); new Th原创 2012-08-17 11:21:15 · 445 阅读 · 0 评论 -
四个线程在卖100张票
package com.cavaness.quartzbook.chapter3;/** * 四个线程在卖100张票 * @author Kevin * */public class Test { public static void main(String[] args) { new TestThread().start(); new TestThread().start原创 2012-08-17 10:35:15 · 7446 阅读 · 0 评论 -
线程通信2
package com.cavaness.quartzbook.chapter3;public class Data { private String name = "unknown"; private String sex = "unknown"; private boolean bFull = false; public synchronized void put(String原创 2012-08-18 09:03:44 · 728 阅读 · 0 评论 -
设计4个线程,其中两个线程每次对j增加1,另外两个线程对j每次减少1。
package com.cavaness.quartzbook.chapter3;public class Test { private int j; private synchronized void inc() { j++; System.out.println(Thread.currentThread().getName() + "-inc:" + j); } pri原创 2012-08-18 10:05:47 · 1519 阅读 · 0 评论 -
输出指定日期范围内的日期列表
import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Calendar;import java.util.Date;import java.util.List;public class FindDates { public static void main(S原创 2016-03-22 09:33:43 · 966 阅读 · 0 评论 -
获取当前星期
public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { System.out.println("Calendar.SUNDAY"); }原创 2016-03-17 13:59:43 · 315 阅读 · 0 评论 -
1.java国际化:资源文件
src/com/bjpowernode/resources/MessagesBundle_en_US.propertiesk1=hello,{0}k2=good byesrc/com/bjpowernode/resources/MessagesBundle_zh_CN.propertiesk1=\u4F60\u597D,{0}k2=\u518D\u89C1k3=\u5C31\u原创 2012-08-26 09:00:38 · 359 阅读 · 0 评论 -
2.java国际化:测试
package com.bjpowernode.i18n;import java.text.MessageFormat;import java.util.Locale;import java.util.ResourceBundle;public class I18nSample { public static void main(String[] args) { // 默认的l原创 2012-08-26 09:00:57 · 542 阅读 · 0 评论 -
try catch finally
package com.cavaness.quartzbook.chapter3;public class DateTest { public static void main(String[] args) { test(); } public static void test() { try { System.out.println("try"); Except原创 2012-08-16 20:52:10 · 336 阅读 · 0 评论 -
finally
package com.cavaness.quartzbook.chapter3;public class DateTest { public static void main(String[] args) { test(); } public static void test() { try { System.out.println("try"); // ret原创 2012-08-16 20:32:08 · 318 阅读 · 0 评论 -
String和StringBuffer
package com.cavaness.quartzbook.chapter3;public class DateTest { public static void main(String[] args) { test(); } public static void test() { System.out.println(new String("abc").equals(n原创 2012-08-16 20:05:43 · 282 阅读 · 0 评论 -
作用域
原创 2012-08-16 14:38:29 · 267 阅读 · 0 评论 -
&&VS&
public void testAnd() { int x = 3; int y = 4; if (x != 3 & ++y > 0) { System.out.println(y); } System.out.println(y); // 5 }public void testAnd() { int x = 3; int y = 4;原创 2012-08-16 10:49:38 · 442 阅读 · 0 评论 -
动态代理
package com.bjpowernode.spring;public interface UserManager { public void addUser(String username, String password); public void delUser(int userId); public String findUserById(int userId);原创 2012-08-29 08:40:44 · 303 阅读 · 0 评论 -
静态代理
package com.bjpowernode.spring;public interface UserManager { public void addUser(String username, String password); public void delUser(int userId); public String findUserById(int userId);原创 2012-08-29 08:40:34 · 308 阅读 · 0 评论 -
strictfp, volatile, transient关键词
Key: strictfp使用对象:类、方法自Java2以来,Java语言增加了一个关键字strictfp,虽然这个关键字在大多数场合比较少用,但是还是有必要了解一下。strictfp的意思是FP-strict,也就是说精确浮点的意思。在Java虚拟机进行浮点运算时,如果没有指定strictfp关键字时,Java的编译器以及运行环境在对浮点运算的表达式是采取一种近似于我行我素的行为来完原创 2012-08-18 14:50:46 · 346 阅读 · 0 评论 -
getClass().getName()
package com.cavaness.quartzbook.chapter3;import java.util.Date;public class Test extends Date { public static void main(String[] args) { new Test().test(); } public void test() { System.o原创 2012-08-18 14:40:50 · 1575 阅读 · 0 评论 -
List
package com.cavaness.quartzbook.chapter3;import java.util.ArrayList;import java.util.Collection;public class Point { private int x; private int y; public Point(int x, int y) { super(); th原创 2012-08-18 10:55:28 · 302 阅读 · 0 评论 -
覆盖equals
package com.cavaness.quartzbook.chapter3;public class Point { private int x; private int y; public Point(int x, int y) { super(); this.x = x; this.y = y; } public int getX() { return原创 2012-08-18 10:50:20 · 408 阅读 · 0 评论 -
两一种启动多线程的方式:Runnable
package com.cavaness.quartzbook.chapter3;public class Test { public static void main(String[] args) { Thread thread = new Thread(new TestThread()); thread.start(); System.out.println("Method原创 2012-08-17 10:00:21 · 559 阅读 · 0 评论 -
前台线程和后台线程
package com.cavaness.quartzbook.chapter3;public class Test { public static void main(String[] args) { // 默认情况下,线程是前台线程,虽然主线程结束了,子线程没结束,那成整个进程(程序)就不会结束 Thread thread = new TestThread(); thread原创 2012-08-17 09:31:29 · 461 阅读 · 0 评论 -
javac -g
ant的javac任务里有对debug信息输出的设置,不过默认是不输出。 javac中设置调试信息级别的选项为-g,其详细含义如下,英文太简单,偶会详细介绍一下: -g Generate all debugging information, including local variables. By default, only line number and source file原创 2012-03-07 16:18:55 · 1763 阅读 · 0 评论 -
classpath
编写java源文件,如果用到了某些类,无论是在编译阶段还是运行阶段,都必须把用的类加到classpath,如果类打成jar包,classpath指定到jar本身,否则指定到类所在的文件夹。加到classpath有两种方法,第一种,在系统环境变量中增加classpath,起到全局的作用,第二种,编译和运行是写上”-classpath 类路径“起到局部的作用。但是,JRE中的类不需要手原创 2012-03-06 10:38:13 · 640 阅读 · 0 评论 -
编译后class文件会不会自动放在跟包名一致的目录下?
写了一个类com.ankangqiao.HelloWorld,文件名叫做HelloWorld.java,我们一般情况把HelloWorld.java放在com\ankangqiao\HelloWorld.java编译它,如果不通过-d指定class文件存放的位置,那么.class文件会存放在跟.java文件同一个地方,并且不会产生跟包名一样的文件夹,比如D:\Workspace原创 2012-03-02 11:42:05 · 852 阅读 · 0 评论 -
运行java和classpath
运行java和classpathpackage com.ankangqiao;public class HelloWorld { /** * @param args */ public static void main(String[] args) { for (int i = 0; i < args.length; i++) { System.out.p原创 2012-03-06 11:08:42 · 414 阅读 · 0 评论 -
编译文件的方法
写了一个类com.ankangqiao.HelloWorld,文件名叫做HelloWorld.java,放在D:\Workspaces\AntTest\src\com\ankangqiao\HelloWorld.java第一种编译方式:D:\Workspaces\AntTest\src\com\ankangqiao>javac HelloWorld.java产生class文件,D:原创 2012-03-02 11:42:18 · 715 阅读 · 0 评论