当前位置:网站首页>【每日一题】第二天
【每日一题】第二天
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名」的原创文章
边栏推荐
- The official docker image running container in version 1.5.1 can be set to use MySQL 8 driver?
- Web实时通信技术之Websocket
- paddlepaddle 28 搭建基于卷积的自动编码机
- Is it safe to buy funds on Alipay account
- 文字编辑器 希望有错误的句子用红色标红,文字编辑器用了markdown
- 夜神模擬器+Fiddler抓包測試App
- What is cloud primordial? This time, I can finally understand!
- Please, stop painting star! This has nothing to do with patriotism!
- Architecture design - ID generator "suggestions collection"
- MySQL 关于 only_full_group_by 限制
猜你喜欢

Leetcode 面试题 17.01. 不用加号的加法

Leetcode 面试题 16.11. 跳水板

工业软件讲堂-三维CAD设计软件的核心技术解析----讲坛第二次讲座

UE4 用spline畫正圓

Wechat nucleic acid detection appointment applet system graduation design completion (4) opening report

Wechat applet video sharing platform system graduation design completion (1) development outline

呆错图床系统源码图片CDN加速与破J防盗链功能

Chrome 正式支持 MathML,默认在 Chromium Dev 105 中启用

Qt官方示例:Qt Quick Controls - Gallery

Wechat nucleic acid detection appointment applet system graduation design completion (1) development outline
随机推荐
Chain game system development (unity3d chain game development details) - chain game development mature technology source code
Wechat nucleic acid detection appointment applet system graduation design (2) applet function
Installation tutorial and simple call of Matplotlib
实施阴影介绍
Wechat applet video sharing platform system graduation design completion (8) graduation design thesis template
初夏,开源魔改一个带击杀音效的电蚊拍!
Rte11 interrupt decoupling function
Leetcode(154)——寻找旋转排序数组中的最小值 II
深度神经网络总结
exness深度好文:动性系列-黄金流动性实例分析(五)
一款简约PHP个人发卡程序V4.0版本
怎么用ps提取图片颜色分析色彩搭配
Wechat applet video sharing platform system graduation design completion (4) opening report
Web version 3D visualization tool, 97 things programmers should know, AI frontier paper | information daily # 2022.07.01
NVIDIA graphics card failed to initialize nvml driver/library version mismatch error solution
MySQL 关于 only_full_group_by 限制
How to use PS to extract image color and analyze color matching
Redis (7) -- database and expiration key
SAP S/4HANA OData Mock Service 介绍
Leetcode interview question 16.15 Abacus wonderful calculation