JAVA_2Lesson
|
package test; public class abc { public static void main(String[] arg) { int[][] xx=new int[3][]; xx[0]=new int[3]; xx[1]=new int[2]; xx[2]=new int[1]; for(int i=0;i<xx.length;++i) for(int j=0;j<xx[i].length;++j) xx[i][j]=j; for(int[] i1:xx) for(int j:i1) System.out.println(j); System.out.println(">>>>>>>>>>>"); int [][] x={{1,2,3},{1,2},{1}}; System.out.println(x[1][1]); } } |
|
package test2_class; public class student { String sName; String sNumber; int sage; public String getsName() { return sName; } public void setsName(String sName) { this.sName = sName; } public String getsNumber() { return sNumber; } public void setsNumber(String sNumber) { this.sNumber = sNumber; } public int getSage() { return sage; } public void setSage(int sage) { this.sage = sage; } void eat() { System.out.println(sName+" have lunch"); } void sleep() { System.out.println(sName+" sleep"); } public boolean equals(Object obj) { student s=(student)obj; if(sName==s.sName&&sage==s.sage&&sNumber==s.sName) { return true; } return false; } public String toString() { return "name:"+sName+"\t"+"age:"+sage+"\t"+"number:"+sNumber; } } |
|
package test2_class; public class Main { public static void main(String[] args) { student t=new student(); t.setsName("zhangsan"); t.setSage(15); t.setsNumber("2678"); System.out.println(t.getSage()); System.out.println(t.getSage()); System.out.println(t.getSage()); t.eat(); t.sleep(); if(t.equals(t)) System.out.println("equal"); System.out.println(t); } } |
|
package string_practice; public class string_practice { public static void main(String[] args) { // TODO Auto-generated method stub String str3="HELLO"; String str4="HELLO"; String str1=new String("HELLO"); String str2=new String("HELLO"); if(str3==str4) { System.out.println("equals"); } if(str1.equals(str2)) { System.out.println("equals"); } Integer a = new Integer(1); } } |
类方法中不能访问非static变量.
导入的两个包有相同名的类,则不导入
final定义常量的关键
JAVA_2Lesson的更多相关文章
随机推荐
- C# Best Practices - Accessing and Using Classes
References and Using Do: Take care when defining references References must be one way (or circular ...
- floyed算法
Floyed算法(实际是动态规划问题) 问题:权值矩阵matrix[i][j]表示i到j的距离,如果没有路径则为无穷 求出权值矩阵中任意两点间的最短距离 分析:对于每一对定点u,v看是否存在一个点w使 ...
- Ubuntu下配置修改IP地址
一.使用命令设置Ubuntu IP地址 1.修改配置文件blacklist.conf禁用IPV6:sudo vi /etc/modprobe.d/blacklist.conf 2.在文档最后添加 bl ...
- spring 框架整合 笔记4
struts hibernate spring 先贴出框架整合需要的maven <project xmlns="http://maven.apache.org/POM/4.0.0&qu ...
- CMake学习小结
假定有vegagis工程,工程的目录结构如下: #--vegagis# |--src 源文件目录# |--gui 界面工程,输出类型:dll,依赖于QT的QtCore.QtGui.QtXml ...
- 移植FreeModbus+ModbusMaster+STM32至RT-Thread(3、4阶段)
一.简介及进展 经过一个多月的努力,目前项目开发已进入最后阶段.虽然比预期时间有些延迟,但也收获不少,边工作边开源的效率确实还有待提高. 简单说下目前的进展吧 1.目前项目已经在Github中开源,大 ...
- hdu 4730 We Love MOE Girls
http://acm.hdu.edu.cn/showproblem.php?pid=4730 直接用string类处理字符串. AC代码: #include<iostream> #incl ...
- iOS Responder Chain 响应者链
一.事件分类 对于IOS设备用户来说,他们操作设备的方式主要有三种:触摸屏幕.晃动设备.通过遥控设施控制设备.对应的事件类型有以下三种: 1.触屏事件(Touch Event) 2.运动事件(Moti ...
- 使用copy函数完成数据库迁移
最近在该一个迁移工具的迁移方式,从ora8迁移到postgresql使用原来的插入迁移速度太慢了,老板说让使用缓存迁移,即使用postgresql的copy函数,因此去pg官网查阅了相关资料,我们需要 ...
- Reapter 添加删除按钮
repeater中的删除按钮和datagrid下的删除在实现上,还是有一定的区别的,由于repeater在客户端生成的html代码是非常干净的,所以特别受到众多web2.0网站的欢迎(不像datagr ...