文章分类 - Java细节
摘要:<jsp:useBean id="user" class="cn.zengfansheng.el.User" scope="page" /> <c:set target="user" property="username" value="hacket"/> <c:set target="user" property="password" value="123456"/> 用户名:$
阅读全文
摘要:package com.test;public class Test { public static void main(String []args) { Integer a = 100;//此处若使用new,则==值必为false Integer b = 100; System.out.println(a==b);//true Integer c = 150; Integer d = 150; System.out.println(c==d);//false }}打印结果很显然。但是如果换成 128 > var >= -128 之外的整...
阅读全文
摘要:Java中null和字符串相"+" 1 public class StringNullDemo 2 { 3 //private static String a; 4 //private static String b; 5 public static void main(String[] args) 6 { 7 /*String c = a + b; 8 String d = "nullnull"; 9 System.out.println(c);//nullnull10 System.out....
阅读全文
摘要:1 class Father 2 { 3 String father = "father"; 4 public void show(){ 5 System.out.println("Father is show()"); 6 } 7 public void show1(){ 8 System.out.println("Father show1111()"); 9 }10 }11 class Son extends Father12 {13 String father = "son";14 ...
阅读全文
摘要:1 public class BreakAndContinueDemo { 2 3 public static void main(String args[]) { 4 5 System.out.println(); 6 System.out.println("循环没有开始"); 7 System.out.println(); 8 System.out.println(); 9 10 System.out.println("现在开始测试continue"); 11 System....
阅读全文
摘要:Java空字符串与null区别:1、类型null表示的是一个对象的值,而并不是一个字符串。例如声明一个对象的引用,String a = null ;""表示的是一个空字符串,也就是说它的长度为0。例如声明一个字符串String str = "" ;2、内存分配String str = null ; 表示声明一个字符串对象的引用,但指向为null,也就是说还没有指向任何的内存空间;String str = ""; 表示声明一个字符串类型的引用,其值为""空字符串,这个str引用指向的是空字符串的内存空间;在java中
阅读全文
摘要:/* 标题:硬币方案 有50枚硬币,可能包括4种类型:1元,5角,1角,5分。 已知总价值为20元。求各种硬币的数量。 比如:2,34,6,8 就是一种答案。 而 2,33,15,0 是另一个可能的答案,显然答案不唯一。 你的任务是确定类似这样的不同的方案一共有多少个(包括已经给出的2个)? 直接提交该数字,不要提交多余的内容。 */public class Coin { public static void main(String[] args) { int i,j,m,n,count=0;//分别代表1元,5角,1角,5分,计数用的 long start = System.cu...
阅读全文
摘要:eclipse中tomcat自动部署时自动停止问题processWorkerExit(w, completedAbruptly)1、问题描述在eclipse或者集成eclipse的其他开发工具中,在tomcat中部署了项目debug模式启动项目,项目启动之后修改项目java源代码,eclipse会自动部署项目到tomcat中。但在tomcat自动重启时会自动停止到processWorkerExit(w,completedAbruptly);这一行代码上。2、问题出现原因原因是因为在java.util.concurrent.ThreadPoolExecutor类中的runWorker(Worke
阅读全文
摘要:今天试了下8.5,发现可以通过 设置选项里面 直接修改,如图:……………………………………………………………………………………………………一般我们第一次启动 MyEclipse 式都会弹出框框 提示您选择 默认工作空间;一般 我们都会勾选 “将此目录作为默认工作空间 并不再 询问”;之后每次启动都不会 有更改空间 的提示,也即 无法直接通过 点击鼠标来设置空间。……………………………………………………………………………………………………当想再次 更改 空间时,可以按如下操作:我的MyEclipse 安装路径:D:\javasoft\MyEclipse找到:D:\javasoft\MyEclip
阅读全文
摘要:1 package q_2013_03_23; 2 3 public class SwapDemo { 4 5 public static void main(String[] args) { 6 7 // 两个数交换 8 swap5(3,5); 9 10 }11 12 // 第三方临时变量-temp13 public static void swap1(int a,int b){14 15 System.out.println("a="+a+":"+"b...
阅读全文
摘要:1 package q_2013_03_23; 2 3 public class ByteDemo { 4 5 public static void main(String[] args) { 6 7 /* byte b = 1+1;//对 8 byte b = (byte) 128; 9 1 System.out.println(b);//-12810 11 */12 13 /* byte b = 1;14 2 b = b...
阅读全文
摘要:1 package q_2013_03_23; 2 3 public class ForKuoHuDemo { 4 5 public static void main(String[] args) { 6 7 for(int i=1;i<=100;i++){ 8 int x = 5; //编译通过,如果不写大括号,代表循环只有一条语句 9 }10 for(int i=1;i<=100;i++)11 int y = 5;//IDE工具报错,x只能在循环中使用,而循环只有一条语句吗,所以...
阅读全文
摘要:1.POST 1 <%2 request.setCharacterEncoding("utf-8"); 3 %>4 <%=5 6 request.getParameter("user") 7 %>POST不管是HTML和JSP内置标签中,都用request.setCharacterEncoding("utf-8");既可以解决乱码问题2.GET 1)如果html基本标签,可以用下面代码解码 但这是jsp标签,这种方式不行了。 String name ...
阅读全文