JavaSE代码
NoBugNoCode
Today is ruthless and tomorrow will be much more ruthless, but the day after tomorrow will turn out to be beautiful. However, most people will die tomorrow night.
展开
-
String固定起始位置字符串反转,去除前后或所有空格
练习字符串的反转如何去除字符串前后空格如何去除字符串所有空格public class StringUtils { //去除前后空格方法 public static String DeleteBlankSpace(String s){ while(s.startsWith(" ")){ s=s.substring(1);原创 2016-10-06 20:07:04 · 744 阅读 · 1 评论 -
String包装类应用之 获取两字符串的最大相同子串
exa: 1.获取两个字符串中最大相同子串。比如: str1 = “abcwerthelloyuiodef”; str2 = “cvhellobnm” 提示:将短的那个串进行长度依次递增的子串与较长 的串比较。public class TestStringContains{ public static void main(String[] args) { String原创 2016-10-06 23:21:07 · 911 阅读 · 0 评论 -
求ax2+bx+c=0方程的根
求ax2+bx+c=0方程的根逻辑练习Math.sqrt()方法使用public static void main(String[] args){ Scanner cin=new Scanner(System.in); int parameter1,parameter2,parameter3,t; while(true){ System.out.pri原创 2016-10-06 19:46:45 · 7166 阅读 · 0 评论 -
this & super 在构造器中如何使用 解析 推理
super 和 this 在构造器中只能有一个 并且放在第一行一、对super 和 this 关键字的描述和理解1、this() super()是在传入当前构造器中的参数或者构造器中的数据 调用其他构造器或者控制父类构造器时使用。2、在一个构造器中你只能使用this()或者super()之中的一个, 而且调用的位置只能在构造器的第一行。 3、在子类中如果你希望调用父类的构造器来初始化父类原创 2016-10-15 23:52:32 · 467 阅读 · 0 评论 -
java基础之数据类型 标识符 跳转语句
一数据类型数据类型的分类 ★1.基本数据类型(8种) 整型: byte :字节整型 short :短整型 int:整型 long:长整型 浮点型: float:单精度 double:双精度 字符型: char:字符型 布尔型: boolean2.原创 2016-10-11 18:14:17 · 555 阅读 · 0 评论 -
账号密码登录(Account password authentication)
账号密码登录(Account password authentication)直到输入账号正确才能输入密码(3次验证机会)并提示剩余次数,(正确的账号和密码信息来自properties文件读取匹配)public class TestAccountPassword { public boolean testAccout() { System.out.println("欢迎进入系原创 2016-10-06 15:45:41 · 12849 阅读 · 0 评论 -
switch case应用-输入年月日判断当年第几天
switch 的简单应用熟练判断是否瑞年熟练使用switch case 的语法 掌握switch case 的执行入口和break结束的位置public class YearDays { public static void main(String[] args) { Scanner cin = new Scanner(System.in); int原创 2016-10-06 18:37:44 · 10027 阅读 · 1 评论 -
String.format() / 字符串拼接格式化输出数据
用String.format()方法格式化输出 或 拼接字符串实现exa: 实现格式化时间,此方法有三个int型参数, 输出类似09:03:12的时间格式 中间需要判断输入的数字是否符合实际情况, 比如小时数就不能大于24,如果大于24就提示输入错误。 public static void main(String[] args) { Scanner cin = new Sc原创 2016-10-06 19:17:54 · 2836 阅读 · 0 评论 -
两层for循环使用之 打印任意行数的菱形图像
for循环的嵌套使用 灵活控制行内的输出内容public static void main(String[] args) { Scanner cin=new Scanner(System.in); System.out.println("请输入要打印的菱形行上三角行数!"); int line=cin.nextInt(); for(int i=1;i<=line;i+原创 2016-10-06 20:00:45 · 1958 阅读 · 0 评论 -
if else 应用之经典例题判断能否构成三角形并输出面积
exa: 有3个整数,给出提示信息: 能否创建三角形;两边之和大于第三边 三个条件都要写 如果能构建三角形,提示是直角三角形还是等边三角形等腰三角形还是普通三角形; 最后输出三角形面积;int t=(a+b+C)/2; int s=sqrt((t-a)(t-b)(t-c)*t);public static void main(String[] args) { Scanner原创 2016-10-06 23:44:36 · 3528 阅读 · 0 评论