商超管理系统项目-成长经历

java编程项目遇到的易错知识点:

1.单引号与双引号的区别:
    • 单引号引的数据 是char类型的
    • 双引号引的数据 是String类型的
    • char定义时用单引号,只能有一个字母,数字。char c='c';
    • 而String用双引号,可以是一个,也可能是多个字母,汉字等。就是所谓的字符串。String s="adsaf";char只是一个基本类型,而String 可以是一个类,可以直接引用。
    • 比如char c='c';不能直接对c调用方法。
    • String s="abc";  这时可以调用s.charAt(0);等方法,因为String是类,这是就是对象的调用了
2.比较符号:
Equals比较的是值   ==比较的是地址   compareTo比较的是ASCII码值
         运行下面的程序结果一目了然:
Integer aInteger=new Integer(4);
Integer bInteger=new Integer("4");
System.out.println(aInteger==bInteger);
System.out.println(aInteger.equals(bInteger));
System.out.print(aInteger.compareTo(bInteger));

3.字符串连接:
</pre><pre name="code" class="java">		// 1
		   String a = "abc";  
		   String b ="def";
		   String c = a+b;
		
		// 2
		   StringBuffer a =new StringBuffer("acb");
		   StringBuffer b =new StringBuffer("123");
		   a.append(b);
		
		//3 第三种方法,必须是String 类型
		   String a = "abc";
		   String b ="def";
		   String c = a.concat(b);
</pre><pre name="code" class="html">4.判断字符串为空:
 
package test;

public class T
{

	/**
	 * 判断字符串是空的方法
	 * 以及效率
	 * 运行一次主函数 比较多次
	 * 
	 * 结论:运行一次,第一次比较时 效率由大到小 :function1() < function1() < function1();
	 * 		运行一次,从第二次开始。三个函数效率基本接近,效率排序不唯一!(估计与缓存有关?)
	 * 
	 * @param args
	 */
	
	static String s = "";
	static long n = 1000000000;
	
	public static void main(String[] args)
	{
		//多打印几次,比较结果
		for (int i = 0; i < 10; i++)
		{
			
			System.out.println("--------"+i);
			function1();
			function2();
			function3();
		}
	}
		//函数1
		private static void function1() 
		{
			   long startTime = System.currentTimeMillis(); //开始时间
	
			   for (long i = 0; i< n; i++)
				{
				     if(s == null || s.equals(""));
				}
			   long endTime = System.currentTimeMillis();//结束时间
			   //打印时间差
			   System.out.println("function 1 use time: "+ (endTime - startTime) +"ms");
		}

		//函数2
		private static void function2()
		{
		   long startTime = System.currentTimeMillis();

		   for(long i = 0; i< n; i++)
		   {
		    <span style="white-space:pre">	</span>if(s == null || s.length() <= 0);
		   }
		   
		   long endTime = System.currentTimeMillis();

		   System.out.println("function 2 use time: "+ (endTime - startTime) +"ms");
		}

		
		//函数3
		private static void function3() 
		{
		   long startTime = System.currentTimeMillis();

		   for(long i = 0; i< n; i++)
		   {   
			 s.isEmpty();
		   }
		   
		   long endTime = System.currentTimeMillis();

		   System.out.println("function 3 use time: "+ (endTime - startTime) +"ms");
		}
	
}
5.性能优化:

5.1 字符串的比较:  
String choice = "abc";
 "0".equals(choice)   这种写法第一保证效率,第二防止空指针异常! {相对于这种写法:choice.equals("0") }

5.2 遍历:

for (int i = 0,length = goodsList.size(); i < length; i++)  
for (int i = 0; i <goodsList.size(); i++)  

①相对于②效率更高。原因:②每遍历一次都要计算 goodsList.size()的大小,而①只需要计算一次,放在栈中即可!

6.小技巧:

没学习正则表达式前,这是一个不错的防止用户输入有误而导致程序挂掉的选择。
<strong>	</strong>boolean bool = true;
	 do
	{	
		 System.out.println("\n重新输入或按 0 返回上一级菜单.");
		 String choice = ScannerChoice.ScannerChoString();
			
			if ("0".equals(choice) || "1".equals(choice))
				{
					bool = false;
					int info = Integer.parseInt(choice); //转成int类型
					switch (info)
					{
					case 0:
						mianPage();
						break;
					case 1:
						GoodsPage.addGoodsPage();
						break;
					default:
						break;
					}
				}
			System.err.println("\t!输入有误!");
	}while(bool);


In Java System.out.println() will print to the standard out of the system you are using. On the other hand, System.err.println() will print to the standard error.

If you are using a simple Java console application, both outputs will be the same (the command line or console) but you can reconfigure the streams so that for example, System.out still prints to the console but System.err writes to a file.

8.java判断list为空

if(null == list || list.size() ==0 ){
}

list.isEmpty()和list.size()==0 没有区别

isEmpty()判断有没有元素
而size()返回有几个元素
如果判断一个集合有无元素 
建议用isEmpty()方法.这清晰,简明

list!=null跟!list.isEmpty()有什么区别?

这就相当与,你要喝水,
前面就是判断是不是连水杯都没有,
后面就是判断水杯里面没有水,
连盛水的东西都没有,
这个水从何而来?
所以一般的判断是
if(list!=null && !list.isEmpty()){
这个里面取list中的值
}else{
做其他处理
}
9.关键字instanceof
uinstanceof是Java的一个二元操作符。它的作用是测试它左边的对象是否是它右边的类的实例,返回boolean类型的数据。可以用在 继承中的子类的实例是否为父类的实现
Animal an = new Animal();
Sheep2 sheep = new Sheep2();
if(an instanceof Animal)
{
	System.out.println("an is Animal's instance");
}
if(sheep instanceof Sheep2)
{
	System.out.println("sheep is Sheep2's instance");
}
if(sheep instanceof Animal)
{
	System.out.println("sheep is Animal's instance");
}



《超市积分管理系统》该项目采用技术jsp、strust2、tomcat服务器、mysql数据库 开发工具eclipse,项目含有源码、论文、配套开发软件、软件安装教程、项目发布教程    超市会员积分管理系统主要用于实现了企业管理数据统计等。本系统结构如下:(1)网络会员管理中心界面:       会员修改密码信息模块:实现会员密码功能;       会员登陆模块:实现会员登陆功能;       会员注册模块:实现会员注册功能;       留言板模块:实现留言板留言功能(2)后台管理界面:       系统用户管理模块:实现管理员的增加、查看功能;       会员信息管理模块:实现会员信息的增加、修改、查看功能;       注册用户管理模块:实现注册用户的增加、修改、查看功能;       会员卡管理模块:实现会员卡信息的增加、查看功能;       商品销售管理模块:实现商品信息的增加、查看功能;       会员积分管理模块:实现合作公司信息的增加、查看功能;       信息统计模块:实现数据统计报表功能;       留言板模块:实现留言板信息的增加、修改、查看功能; 课程目标:    1、学会各类开发软件安装、项目导入以及项目发布,含项目源码,需求文档,配套软件等    2、该项目主要功能完善,主要用于简历项目经验丰富,以及毕业设计或者二次开发    3、提供项目源码,设计文档、数据库sql文件以及所有配套软件,按照教程即可轻松实现项目安装部署 本课程为素材版,需要实战版代码讲解教程的同学可以点击如下链接:java项目实战之电商系统全套(前台和后台)(java毕业设计ssm框架项目)https://edu.csdn.net/course/detail/25771java项目之oa办公管理系统(java毕业设计)https://edu.csdn.net/course/detail/23008java项目之hrm人事管理项目(java毕业设计)https://edu.csdn.net/course/detail/23007JavaWeb项目实战之点餐系统前台https://edu.csdn.net/course/detail/20543JavaWeb项目实战之点餐系统后台https://edu.csdn.net/course/detail/19572JavaWeb项目实战之宿舍管理系统https://edu.csdn.net/course/detail/26721JavaWeb项目实战之点餐系统全套(前台和后台)https://edu.csdn.net/course/detail/20610java项目实战之电子商城后台(java毕业设计SSM框架项目)https://edu.csdn.net/course/detail/25770java美妆商城项目|在线购书系统(java毕业设计项目ssm版)https://edu.csdn.net/course/detail/23989系统学习课程:JavaSE基础全套视频(环境搭建 面向对象 正则表达式 IO流 多线程 网络编程 java10https://edu.csdn.net/course/detail/26941Java Web从入门到电商项目实战挑战万元高薪(javaweb教程)https://edu.csdn.net/course/detail/25976其他素材版(毕业设计或课程设计)项目:点击老师头像进行相关课程学习
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值