摘要: 将String转换成intint guess = Integer.parseInt(stringGuess); 阅读全文
posted @ 2013-12-22 23:51 宫爆菊花超 阅读(129) 评论(0) 推荐(0)
摘要: class Node{ private String data;//要包装的数据 private Node next;//保存它的下一个节点 public Node(String data){//Node 类的功能一定要包装数据 this.data=data; } public void setNode(Node next){ this.next = next; } public String getNode(){ return this.data; } }手工配置并配置节点之间的关系,cl... 阅读全文
posted @ 2013-12-04 17:48 宫爆菊花超 阅读(274) 评论(0) 推荐(0)
摘要: this.属性:表示操作的当前类中的属性,而且也强调了,只要是类中的属性前面都要加上”this“;this.方法():表示的是类中的操作方法;this():表示调用类中的构造方法,但是在使用此语句调用的时候一定要留有出口,必须放在构造方法的首行;this表示当前对象:当前正在操作类的方法的对象,称为当前对象; 阅读全文
posted @ 2013-12-02 13:03 宫爆菊花超 阅读(133) 评论(0) 推荐(0)
摘要: 今天有同学问C语言中for循环里那个 i++ 和 ++i 是否有区别,我告诉他在for循环中是没有区别的,现在具体说一下 i++ 和 ++i 的区别。我们先用while语句写一下 for(i=1;i int main(){ int i,x;i=1; x=1; x=i++; //这里先让X变成i的值1,然后i加1 printf("%d ",x);i=1; x=1; x=++i; //这里先让i加1,然后让X变成i的值2 printf("%d ",x); system("pause"); return 0; }试着运行一下这段程序,发现结 阅读全文
posted @ 2013-12-01 15:17 宫爆菊花超 阅读(261) 评论(0) 推荐(0)
摘要: 1、三目运算符 (表达式1)?(表达式2):(表达式3),计算方法是这样的:表达式1是一个逻辑表达式,如果其值为true,则整个表达式的值为表达式2的值,否则为表达式3的值2、例子:int i = (5 > 3) ? (5 + 3) : (5 - 3);结果为i = 8.因为5 > 3为true,所以i = 5 + 3. 3、根据三目运算符的从右到左的结合性,我是这样划分的year > a.year ? 1 : (year a.month ? 1 : (month a.day ? 1 : (day < a.day ? -1 : 0)))));所以应该从最右边的那个表达式 阅读全文
posted @ 2013-12-01 13:19 宫爆菊花超 阅读(315) 评论(0) 推荐(0)
摘要: //导包import java.util.Scanner; public class TextScanner{ public static void main(String [] args){ //创建Scanner对象 接受从控制台输入 Scanner input = new Scanner(System.in); System.out.println("请输入名字:"); //接受String型 String name = input.next(); System.out.println("请输入学号"); //接受int型 int id = inp 阅读全文
posted @ 2013-12-01 11:53 宫爆菊花超 阅读(157) 评论(0) 推荐(0)
摘要: public static void reverse(Person temp []){//接收数组int center=temp.length / 2;//取中间点int head = 0;//开始点int tail =temp.length - 1;//for(int x=0;x<center;x++){//运行条件Person p = temp[head];//交换数组temp[head]=temp[tail];temp[tail]= p;head++;tail--; 阅读全文
posted @ 2013-11-28 13:27 宫爆菊花超 阅读(272) 评论(0) 推荐(0)