• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • YouClaw
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
 






许先

 
 

Powered by 博客园
博客园 | 首页 | 新随笔 | 联系 | 订阅 订阅 | 管理

随笔分类 -  实用类介绍

 
17. 处理日期
摘要:import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Test { public static void main(String[] args) { Date date = new Date(); //创建日期对象 ... 阅读全文
posted @ 2016-05-28 00:58 许先 阅读(148) 评论(0) 推荐(0)
16.查找特定字符出现的次数
摘要:import java.util.Scanner; public class Counter { public int counter(String inputs,String word){ int counter=0;//计数器,初始化0 String[] temps=new String[inputs.length()]; ... 阅读全文
posted @ 2016-05-28 00:58 许先 阅读(559) 评论(0) 推荐(0)
15.字符串长度
摘要:import java.util.*; public class Register { /** * 注册密码长度不少于6位 */ public static void main(String[] args) { Scanner input = new Scanner(System.in); String uname,pwd; ... 阅读全文
posted @ 2016-05-28 00:55 许先 阅读(203) 评论(0) 推荐(0)
13.字符串比较
摘要:import java.util.*; public class Login { /** * 登录 */ public static void main(String[] args) { Scanner input = new Scanner(System.in); String uname,pwd; ... 阅读全文
posted @ 2016-05-28 00:54 许先 阅读(166) 评论(0) 推荐(0)
14.字符串拆分
摘要:public class Lyric { /** * 拆分歌词 * */ public static void main(String[] args) { String words="长亭外 古道边 芳草碧连天 晚风扶 柳笛声残 夕阳山外山"; String[] printword=new String[100];... 阅读全文
posted @ 2016-05-28 00:54 许先 阅读(145) 评论(0) 推荐(0)
12.幸运抽奖
摘要:import java.util.Scanner; /* * 幸运抽奖:会员号的百位数与系统随机数相同,即为中奖 * */ public class GoodLuck { public static void main(String[] args) { //随机产生一个0-9之间的任意整数 int random=(int)(Math.ran... 阅读全文
posted @ 2016-05-28 00:53 许先 阅读(175) 评论(0) 推荐(0)
11.使用枚举
摘要://一周七天的枚举 public enum Week { MON,TUE,WED,THU,FRI,SAT,SUN } public class WeekDemo1 { /** * 做什么事情 * */ public void doWhat(int day){ //使用条件判断 if(day>7 || day<1){ ... 阅读全文
posted @ 2016-05-28 00:52 许先 阅读(213) 评论(0) 推荐(0)
10.获取系统时间
摘要:import java.text.SimpleDateFormat; import java.util.Date; public class Test { public static void main(String[] args) { Date date = new Date(); //创建日期对象 SimpleDateFormat formater =... 阅读全文
posted @ 2016-05-28 00:50 许先 阅读(146) 评论(0) 推荐(0)
9.包装类的构造方法
摘要:public class Demo { public static void main(String[] args) { //所有包装类都可将与之对应的基本数据类型作为参数,来构造它们的实例 Integer i=new Integer(34); Double d=new Double(98.7); Boolean b=new... 阅读全文
posted @ 2016-05-28 00:49 许先 阅读(348) 评论(0) 推荐(0)
8.包装类常用方法
摘要:/** * 包装类常用方法 * */ public class Demo { public static void main(String[] args){ //XXXValue():包装类转换成基本类型 Integer integerId=new Integer(25); int intId=integerId.intValue()... 阅读全文
posted @ 2016-05-28 00:48 许先 阅读(342) 评论(0) 推荐(1)
7.StringBuffer类的使用
摘要:package cn.jbit.classandobject; import java.util.*; public class TestInsert { /** * 每隔三位插入逗号 * */ public static void main(String[] args) { Scanner input = new... 阅读全文
posted @ 2016-05-28 00:47 许先 阅读(227) 评论(0) 推荐(0)
6.Random类
摘要:import java.util.Random; public class RandomDemo { public static void main(String[] args) { Random rand=new Random(); //创建一个Random对象 for(int i=0;i<20;i++){//随机生成20个随机整数,并显示 ... 阅读全文
posted @ 2016-05-28 00:46 许先 阅读(162) 评论(0) 推荐(0)
5. 字符串提取
摘要:1 import java.util.*; 2 3 public class Verify{ 4 public static void main(String[] args) { 5 // 声明变量 6 boolean fileCorrect = false; //标识文件名是否正确 7 boolean emailC... 阅读全文
posted @ 2016-05-28 00:45 许先 阅读(141) 评论(0) 推荐(0)
4.字符串连接
摘要:public class PrintScore { /** * 打印成绩单 * */ public static void main(String[] args) { int sqlScore = 80; //SQL成绩 int javaScore = 90; //Java... 阅读全文
posted @ 2016-05-28 00:41 许先 阅读(163) 评论(0) 推荐(0)
2.Calendar类的使用
摘要:import java.util.Calendar; public class Test { public static void main(String[] args) { Calendar t = Calendar.getInstance(); System.out.println("今天是"+t.get(Calendar.YEAR)+"年" ... 阅读全文
posted @ 2016-05-28 00:40 许先 阅读(191) 评论(0) 推荐(0)
3. 忽略大小写的字符串比较
摘要:import java.util.*; public class Login { /** * 登录 * */ public static void main(String[] args) { Scanner input = new Scanner(System.in); String uname,pwd; ... 阅读全文
posted @ 2016-05-28 00:40 许先 阅读(318) 评论(0) 推荐(0)
1.==和equals()
摘要:public class StrEqu { public static void main(String[] args) { String str1="bdqn"; String str2="bdqn"; System.out.println(str1==str2); System.out.println(str1.equa... 阅读全文
posted @ 2016-05-28 00:39 许先 阅读(485) 评论(0) 推荐(0)