❤️ Author: 老九
☕️ 个人博客:老九的CSDN博客
🙏 个人名言:不可控之事 乐观面对
😍 系列专栏:每日一题


toLowerCase不是在本身修改,而是产生了一个新的对象,底层源码是new了一个新的string,而如果本身是小写的,就返回this,不会new一个新的对象

先创建了一个新的对象,里面的是静态方法,静态方法不依赖于对象,所以可以编译通过正确运行

子类的构造方法必须调用父类的构造方法,如果使用super()就显示调用父类的构造方法了,this和super不能出现在同一个构造函数中,也不能在static环境中使用,因为要依赖对象

创建子类的对象默认调用父类的构造方法

static不能定义局部变量,只能定义静态成员变量,也不能放在静态方法中

abstract不能修饰字段
抽象方法不能加大括号

类中的constructor(构造方法)可以省略,构造方法必须和类重名,但方法也可以和类重名,构造方法可以重载

对成员变量的赋值必须在方法中实现


整体数据进行逆置
然后每个单词进行逆置
public class test1 {
public static void reverse(char[] array,int start,int end){
while(start < end){
char tmp = array[start];
array[start] = array[end];
array[end] = tmp;
start ++;
end --;
}
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String s = scan.nextLine();
char[] ch = s.toCharArray();
int len = ch.length;
//整体进行了逆置
reverse(ch,0,len-1);
int i = 0;//遍历数组
while(i<len){
int j = i;
while(j<len && ch[j] != ' '){
j++;
}
if(j<len){
reverse(ch,i,j-1);
i=j+1;
}else{
reverse(ch,i,j-1);
i= j;
}
}
String str = new String(ch);
System.out.println(str);
}
}


public class test1 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int [] array = new int[n+1];
for(int i = 0;i<n;i++){
array[i]=scan.nextInt();
}
int i = 0;
int count = 0;
while(i<n){
if(array[i]<array[i+1]){
while(i<n && array[i]<array[i+1]){
i++;
}
count++;
i++;
}else if(array[i] == array[i+1]){
i++;
}else{
while(i<n && array[i]>array[i+1]){
i++;
}
count++;
i++;
}
}
System.out.println(count);
}
}
————————————————————————
♥♥♥码字不易,大家的支持就是我坚持下去的动力♥♥♥
版权声明:本文为CSDN博主「亚太地区百大最帅面孔第101名」的原创文章