23. public static int lastIndexOf(String str, char searchChar) 基本原理同18 24. public static int lastIndexOf(String str, char searchChar, int startPos) 基本原理同19 25. public static int lastIndexOf(String str, String searchStr) 基本原理同20 26. public static int lastIndexOf(String str...
abstract public String toString(); } class Circle extends Shape { public String toString() { return "Circle"; } } class Square extends Shape { public String toString() { return "Square"; } } class Triangle extends Shape { public String toString() { return "Triangle"; } } 1. 2. 3. ...
}/*** 1、设计一个方法,返回指定位数的验证码*/publicstaticString createCode(intn){//2、定义2个变量 一个是记住最终产生的随机验证码 一个是记住可能用到的全部字符String code = ""; String data= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; Random r=newRandom();//3、开始定义...
publicclassStringDemo2{publicstaticvoidmain(String[]args){//目标:快速熟悉String提供的处理字符串的常用方法。Strings="黑马Java";// 1、获取字符串的长度System.out.println(s.length());// 2、提取字符串中某个索引位置处的字符charc=s.charAt(1);System.out.println(c);// 字符串的遍历for(inti=0;i...
int indexOf(int ch,int fromIndex):从fromIndex指定的位置开始,获取ch在字符串中出现的位置。 我们不光可以获取字符在字符串中的位置,还可以获取字符串在字符串中的位置。 int indexOf(String str) int indexOf(String str,int fromIndex) 接下来做一个演示~ ...
price = price; } public int getCount() { return count; } public void setCount(int count) { this.count = count; } } package com.itheima.test3; public class GoodsTest { public static void main(String[] args) { //1.创建一个数组 Goods[] arr = new Goods[3]; //2.创建三个商品...
百家姓字符串数组 代码语言:javascript 复制 privatestaticfinal String[]NAME_LIST={"赵","钱","孙","李","周","吴","郑","王","冯","陈","褚","卫","蒋","沈","韩","杨","朱","秦","尤","许","何","吕","施","张","孔","曹","严","华","金","魏","陶","姜","...
out,使参数按引用传递即方法内改变参数的值,也会影响到方法外的值不定长参数如int...如params int...
Collection<String> lists =newArrayList<>();//JDK 1.7开始后面的泛型类型申明可以省略不写注意:集合和泛型都只能支持引用数据类型,不支持基本数据类型,所以集合中存储的元素都认为是对象。Collection<int> lists =newArrayList<>();//不支持如果集合中要存储基本类型的数据怎么办?//存储基本类型使用包装类Collection<...
privatestaticclassIntegerCache{staticfinal int low=-128;staticfinal int high;staticfinal Integer cache[];static{// high value may be configured by propertyint h=127;String integerCacheHighPropValue=sun.misc.VM.getSavedProperty("java.lang.Integer.IntegerCache.high");if(integerCacheHighPropValue!=null...