
JAVA基础
文章平均质量分 53
普通网友
这个作者很懒,什么都没留下…
展开
-
类与对象
class Person{ public final String x ="abc";//final 对象不能被修改 public String name; public int age; public Person(String name,int age) { this.name = name; this.age = age; } public void getInfo() { Syste原创 2010-01-15 15:24:00 · 387 阅读 · 0 评论 -
枚举 Enum
enum Person{ 张三("脾气暴躁"),关公("讲义气"),刘备("爱哭"); private String feature; private Person(String feature) { this.feature = feature; } public String getFeature(){ return this.reature; }原创 2012-02-15 15:13:45 · 279 阅读 · 0 评论 -
昨天面试的一道编程题 将人民币大写转换成数字,并且保证数据不能超过一亿
昨天面试的一道题,当时我是把答案写在纸上,也没有用IDE调今天再写一遍,测试通过,这样也证明了我的思路是正确的。下面这段代码还可以写得更优美点,比如用静态方法等。 /** * 将人民币大写转换成数字,并且保证数据不能超过一亿 * @author joeho * */public class RMBFormatOutPut { /** * 测试输入 * @param args */ p原创 2010-04-17 13:16:00 · 936 阅读 · 0 评论 -
类与对象
/**类与对象*/class Person{ private int age; private String name; //构造函数 public Person() { age = 60; System.out.println("construct1 is calling----"); } public Person(String name,int age) { this.name =原创 2010-01-14 16:24:00 · 270 阅读 · 0 评论 -
数组
class lesson23{ public static void main(String args[]) { int x[]=new int[100]; int sum=0; for(int i=0;i { x[i]=i; sum+=x[i]; } System.out.println(sum); int xx[][]=new int[2][3]; xx[0][0]原创 2010-01-14 13:33:00 · 286 阅读 · 0 评论 -
基础 PATH&CLASSPATH
class test1{ public static void main(String args[]){ System.out.println("Hello,test1"); }}/*PATH 系统执行命令时,只会在PATH目录中去寻找。classpath当我们在设置了CLASSPATH环境变量时,执行JAVA命令后,JAVA虚拟机不再从当前目录去查找编译后的JAVA文件,而是直接在指定原创 2010-01-14 12:42:00 · 336 阅读 · 0 评论 -
线程同步
class Producer implements Runnable{ Buffer q; public Producer(Buffer q) { this.q=q; } public void run() { int i=0; while(true) { /* synchronized(q)// { if(q.bFull) try{q.wait();}catc原创 2010-01-17 10:42:00 · 257 阅读 · 0 评论 -
异常
class Test{ public int devide(int x,int y) throws ArithmeticException,DevideByMinueException { if(y throw new DevideByMinueException("除数为"+y); int result = x/y; return result; }}class DevideByM原创 2010-01-16 15:37:00 · 282 阅读 · 0 评论 -
IO之ObjectOutputStream
package joeho.net.csdn.blog.io;import java.io.*; class EmployeeSerial implements Serializable{ private String name = ""; private String departName = ""; private int age = 0; private int employe原创 2010-01-19 23:54:00 · 429 阅读 · 0 评论 -
IO之Reader Writer
package joeho.net.csdn.blog.io;import java.io.*;import java.nio.*;public class FileWriterReader { /** * Method main * * * @param args * */ public static void main(String[] args) throws Except原创 2010-01-19 00:32:00 · 383 阅读 · 0 评论 -
接口例子
interface PCI{ void start(); void stop();}class VedioCard implements PCI{ public void start() { System.out.println("start vedio--- "); } public void stop() { System.out.println("stop vedio-----");原创 2010-01-15 18:07:00 · 516 阅读 · 0 评论 -
抽象类接口
//抽象类不能产生任何实例对象//接口是一种特殊的抽象类,/*abstract class A{ abstract void aa(int x,String str);} class B extends A{ void aa(int x,String str) { } }*///接口中所有的方法默认的是publicinterface Runner{ int ID = 1; void run()原创 2010-01-15 18:06:00 · 242 阅读 · 0 评论 -
static 及简单的单态设计模式
class PassParam{ int x; public static void main(String args[]) { /* int x=5; change(x); System.out.println(x); */ PassParam obj = new PassParam(); obj.x=5; change(obj); System.out.println(obj原创 2010-01-15 10:08:00 · 426 阅读 · 0 评论 -
内部类
class Outer{ int count_1=100; void test() { Inner iner=new Inner(); iner.display(); } class Inner//如果将内部类类名前加上关键字static,那么内部类将变成外部类 { void display() { System.out.println("count_1 ="+count_1);原创 2010-01-15 10:17:00 · 301 阅读 · 0 评论 -
选择 循环
/**author:joeho*/class lesson22{ public static void main(String []args) { int x=2; if(x { System.out.println("x System.out.println("OK"); } else if(x>=3&&x System.out.println("x>=3&&x原创 2010-01-14 12:58:00 · 322 阅读 · 0 评论 -
基础 函数 类型
class lesson2{ public static void main(String args[]){ //System.out.println("Hello world"); /* int x,y; //y=x=3; y=x=0+3; System.out.println("y="+y); */ //char ch=97; char ch=a; int x=ch;原创 2010-01-14 12:54:00 · 253 阅读 · 0 评论