第3章 面向对象基础知识

String类的常用方法

public String(char[] value)
public String(char[] value, int offset, int count)
public char charAt(int index)
public char[] toCharArray()

public String(byte[] bytes)
public String(byte[] bytes, int offset, int length)
public byte[] getBytes()
public byte[] getBytes(String charsetName)throws UnsupportedEncodingEception

public boolean equals(String anObject)
public boolean equalsIgnoreCase(String anotherString)
public int compareTo(String anotherString)
public boolean contains(String s)
public int indexOf(String str)
public int indexOf(String str, int fromIndex)
public int lastIndexOf(String str)
public int lastIndexOf(String str, int fromIndex)
public boolean startsWith(String prefix)
public boolean startsWith(String prefix, intoffset)
public boolean endsWith(String suffix)

public String replaceAll(String regex, String replacement)
public String replaceFirst(String regex, String replacement)

public String substring(int beginIndex) 
public String substring(int beginIndex, int endIndex)

public String[] split(String regex)
public String[] split(String regex, int limit)
public String concat(Stirng str)

public String toLowerCase()
public String toUpperCase()
public String trim()
public int length()
public String intern()
public boolean isEmpty()

数据表一对多关系转为类间关系

一个部门Dept有多个雇员Emps

要根据部门取出雇员信息

class Dept {
    private Emp[] emps ;
    public void setEmp() {
        this.emps = emps;
    }
    public Emp[] getEmps() {
        return this.emps;
    }
}

class Emp {

}   

public class Test {
    System.out.println(dept.getInfo());
    for(int x=0; x < dept.getEmps().length; x++) {
        System.out.println(dept.getEmps()[x].getInfo());
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值