- 博客(33)
- 收藏
- 关注
原创 Arrays - 判断两个数组是否一致 以及常用的判断
package ArrayTest;import java.util.Arrays; //Arrays提供的静态方法public class classtest { //判断两个数组是否相等 public static boolean isEquals(int[] a,int[] b) { if(a == null || b ==null)
2011-10-24 21:24:28 472
原创 Java中数组的使用及注意事项
package ArrayTest;public class test2 { public static void main(String[] args) { Student[][] a = new Student [3][]; //二维 不规整数组 a[0]=new Student[2]; //一维 a[1
2011-10-24 20:17:50 602
原创 原生数据类型
package test;//原生数据类型public class IntegerTest { public static void main(String[] args) { int a = 10; Integer integer = new Integer(a); int b = integer.intValue(); System.
2011-10-21 20:03:12 366
原创 StringBuffer(字符串追加)
package test;public class stringbuffer { public static void main(String[] args) { StringBuffer sb = new StringBuffer(); sb.append("Hello").append(" World").append( " Java").append(100).app
2011-10-21 19:36:59 3084
原创 结构体,数组
#include using namespace std;struct Date{ int year; int month; int day;};struct Student{ int num; char name[20]; cha
2011-10-18 21:04:33 310
原创 结构体(struct)
#include using namespace std;struct Date{ int year; int month; int day;};struct Student{ int num; char name[20]; cha
2011-10-18 20:27:06 314
原创 Object类以及子类的toString()方法的使用及重写
public class ObjectTest { public static void main(String[] args) { Object object = new Object(); System.out.println(object);
2011-10-14 22:41:27 808
原创 instanceof的使用
public class InstanceOf { public static void main(String[] args) { People people = new People(); System.out.println(people instanc
2011-10-14 21:35:56 213
原创 单例模式
//单例模式(单态模式)public class singleton { public static void main(String[] args) { Singleton1 singleton = Singleton1.getInstance(); /
2011-10-13 22:26:58 361
原创 final修饰类,方法,属性
public class FinalTest { final int a ; // final类型的值(1)可以在定义的时候初始化,之后就不可以改变了 。 public FinalTest() //final类型的值(2)或者通过构造函数
2011-10-12 22:27:43 4250
原创 静态与非静态方法,静态代码块,程序代码块的用法
//非静态的函数可以访问静态的或者非静态的成员变量//静态的只能访问静态的成员变量public class statictest { public static void main(String[] args) { P p = new P();
2011-10-12 20:35:25 463
原创 静态代码块(static block)
public class statictest { public static void main(String[] args) { P p = new P(); P p1 = new P(); }}class P{ static {
2011-10-12 19:45:20 435
原创 指针作为函数参数
#include using namespace std;int main(){ void swap(int *p1,int *p2); int *p1,*p2,*p,a,b; cin>>a>>b; p1=&a; p2=&b; if(a
2011-10-06 20:04:30 229
原创 字符串数字前添加*
#include #include using namespace std;char *fun(char* s){ int i,j; int len = strlen(s); for(i=0;i if((*(s+i))>
2011-10-05 20:10:25 722 1
原创 接口在多态中的具体应用
public class interfacetest2 { public static void main(String[] args) { /* AA bb = new BB(); //接口类型的引用指向了实现接口类的实例 bb.output();
2011-10-03 21:19:43 294
原创 接口的实现
public class interfacetest { public static void main(String[] args) { Myclass myclass = new Myclass (); myclass.output(); mycla
2011-10-03 21:02:07 249
原创 抽象方法(abstract class)的作用体现
public class AbstractTest2 { public static void main(String[] args) { Shape shape = new Triangle (10 , 5); //传递参数给构造函数
2011-10-03 20:04:05 727
原创 抽象类(abstract class)的继承
public class AbstractTest { public static void main(String[] args) { // R r = new R(); //抽象类不能实例化 // r.method(); }}a
2011-10-03 19:41:44 740
原创 多态实际开发中的用途
//屏蔽子类间的差异性,用一个公共的父类来去标识着接口public class PolyTest5 { /* public void run(BMW bmw) //定义BMW的run方法 { bmw.run(); } public v
2011-10-02 22:57:55 672
原创 多态运行期的行为 --(晚绑定)
public class PolyTest4 { public static void main(String[] args) { A a = null; if (args[0].equals("1")) { a = new B(); } else
2011-10-02 22:12:27 291
原创 多态(Polymorphism)的强制类型转换2
class PolyTest3 { public static void main(String[] args) { //Fruit f = new Pear(); //f.run(); //Pear p = (Pear)f; //f.ru
2011-10-02 21:59:37 284
原创 多态(Polymorphism)的强制类型转换
public class PolyTest2 { public static void main(String[] args) { /* Animal a = new Dog(); Dog dog = (Dog) a; //向下转换:它指向什么样的对
2011-10-02 21:42:42 266
原创 输出平均数 (通过传递程序参数实现)
public class Average { public static void main(String[] args) { double n,sum=0.0; for(int i=0;i { sum=sum+Double.v
2011-10-02 19:33:42 310
原创 数组(Array)的复制
public class UseArray { public static void main(String[] a) { int[] s={2,6,1,3}; int[] s2=new int[s.length];//s2动态初始化分配空
2011-10-02 19:13:23 754
原创 对话框 JOptionPane
import javax.swing.JOptionPane;public class Dialog { public static void main(String[] args) { JOptionPane.showMessageDia
2011-10-02 19:10:42 232
原创 继承(Inheritance)
public class Fruit { public static void main(String[] args) { Apple apple =new Apple(); System.out.println(apple.name); }}cl
2011-10-02 19:09:14 273
原创 Scanner包
import java.util.Scanner;public class shuzu { public static void main(String[] args) { int i=0,j=0,sum=0; Scanner scan
2011-10-02 19:07:32 689
原创 重载(OverLoad)
public class OverloadTest { public int add(int a,int b) { return a + b; } public int add(int a,int
2011-10-02 19:06:46 195
原创 引用2
public class ParamTest { public void change(Person person,Person person2) { person.name = "lisi"; person2.name = "wangwu";
2011-10-02 19:05:15 227
原创 引用(Peference)
public class People { int age; public void change(int i) { i++; } public void change2(People p) { p=new
2011-10-02 19:03:46 497
原创 double类型小数的二进制转换
public class Float { public static void main(String[] args) { System.out.println(1.0-0.9); //结果为0.099999999999999
2011-10-02 19:02:47 961
原创 素数
public class shushu { public static void main(String[] args) { int i,j; for(i=2;i { for(j=2;j {
2011-10-02 19:00:55 195
翻译 多态(Plolymorphism)
public class PolyTest { public static void main(String[] args) { //Parent parent = new Parent(); //parent.sing(); //Child chi
2011-10-02 18:58:43 239
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人