当前位置:网站首页>【每日一题】第二天
【每日一题】第二天
2022-07-02 17:09:00 【亚太地区百大最帅面孔第101名】
️ Author: 老九
️ 个人博客:老九的CSDN博客
个人名言:不可控之事 乐观面对
系列专栏:每日一题
选择
toLowerCase不是在本身修改,而是产生了一个新的对象,底层源码是new了一个新的string,而如果本身是小写的,就返回this,不会new一个新的对象
先创建了一个新的对象,里面的是静态方法,静态方法不依赖于对象,所以可以编译通过正确运行
子类的构造方法必须调用父类的构造方法,如果使用super()就显示调用父类的构造方法了,this和super不能出现在同一个构造函数中,也不能在static环境中使用,因为要依赖对象
创建子类的对象默认调用父类的构造方法
static不能定义局部变量,只能定义静态成员变量,也不能放在静态方法中
abstract不能修饰字段
抽象方法不能加大括号
类中的constructor(构造方法)可以省略,构造方法必须和类重名,但方法也可以和类重名,构造方法可以重载
对成员变量的赋值必须在方法中实现
编程题1
整体数据进行逆置
然后每个单词进行逆置
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);
}
}
编程题2
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名」的原创文章
边栏推荐
- 如何设置VSCode删除整行快捷键?
- Interview, about thread pool
- Wechat applet video sharing platform system graduation design (2) applet function
- Leetcode 面试题 16.11. 跳水板
- SteamOS 3.3 Beta 发布,Steam Deck 中文键盘终于来了
- iptable端口重定向 MASQUERADE[通俗易懂]
- Iframe nesting details
- Relax again! These fresh students can settle directly in Shanghai
- Night God simulator +fiddler packet capture test app
- Three ways of function parameter transfer in C language
猜你喜欢
Wechat nucleic acid detection appointment applet system graduation design completion (5) task statement
Web version 3D visualization tool, 97 things programmers should know, AI frontier paper | information daily # 2022.07.01
SteamOS 3.3 Beta 发布,Steam Deck 中文键盘终于来了
Leetcode interview question 16.15 Abacus wonderful calculation
[Yugong series] July 2022 go teaching course 001 introduction to go language premise
Pit encountered during installation of laravel frame
Picking up the camera is the best artistic healing
初夏,开源魔改一个带击杀音效的电蚊拍!
Leetcode 面试题 17.01. 不用加号的加法
一款简约PHP个人发卡程序V4.0版本
随机推荐
PR曲线和ROC曲线概念及其区别
QQmlApplicationEngine
Is it safe to buy funds on Alipay account
Summary of fun free GM games
Chrome officially supports MathML, which is enabled in chromium dev 105 by default
The text editor hopes to mark the wrong sentences in red, and the text editor uses markdown
如何清理废弃pv和其对应的文件夹
How to use PS to extract image color and analyze color matching
Responses of different people in technology companies to bugs | daily anecdotes
Wechat applet video sharing platform system graduation design completion (7) Interim inspection report
Leetcode interview question 17.01 Addition without plus sign
Relax again! These fresh students can settle directly in Shanghai
如何优雅的写 Controller 层代码?
Simulateur nightGod + application de test de capture de paquets Fiddler
如何设置VSCode删除整行快捷键?
NM02-独立于总线协议的NM模块调用序列图及代码解释
Meta universe chain game system development (logic development) - chain game system development (detailed analysis)
How to write controller layer code gracefully?
Leetcode interview question 17.04 Vanishing numbers
ESP32-C3入门教程 问题篇⑩——error: implicit declaration of function ‘esp_blufi_close‘;