当前位置:网站首页>[daily question] the next day
[daily question] the next day
2022-07-02 18:50:00 【No. 101 of the top 100 most handsome faces in the Asia Pacific 】
️ Author: intellectuals
️ Personal blog : Old nine CSDN Blog
Personal famous saying : Uncontrollable things Optimistic face
Series column : A daily topic
List of articles
choice
toLowerCase Not in itself , Instead, a new object is created , The underlying source code is new A new one string, And if it is lowercase , Just go back to this, Can't new A new object
First create a new object , Inside are static methods , Static methods don't depend on objects , So it can be compiled and run correctly
The constructor of the subclass must call the constructor of the parent class , If you use super() It shows the constructor of calling the parent class ,this and super Cannot appear in the same constructor , Nor in static Use in the environment , Because it depends on objects
The object that creates the subclass calls the constructor of the parent class by default
static Cannot define local variables , Only static member variables can be defined , Nor can it be placed in static methods
abstract Fields cannot be decorated
Abstract methods cannot be bracketed
Class constructor( Construction method ) It can be omitted , Constructor must have the same name as the class , But methods can also have the same name as classes , Constructors can be overloaded
The assignment of member variables must be implemented in methods
Programming questions 1
Reverse the overall data
Then reverse each word
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;
// The whole is reversed
reverse(ch,0,len-1);
int i = 0;// Traversal array
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);
}
}
Programming questions 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);
}
}
————————————————————————
It's not easy to code words , Everyone's support is my driving force to stick to it
Copyright notice : This paper is about CSDN Blogger 「 The top 100 most handsome faces in the Asia Pacific region 101 name 」 The original article of
边栏推荐
- 一款简约PHP个人发卡程序V4.0版本
- Competence of product manager
- 300+篇文献!一文详解基于Transformer的多模态学习最新进展
- Nm01 function overview and API definition of nm module independent of bus protocol
- “栈”的典型应用—表达式求值(C语言实现)
- Leetcode 面试题 16.17. 连续数列
- SLC、MLC、TLC 和 QLC NAND SSD 之间的区别:哪个更好?
- Thoroughly understand the point cloud processing tutorial based on open3d!
- Leetcode(81)——搜索旋转排序数组 II
- Web实时通信技术之Websocket
猜你喜欢
再放寬!這些應届生,可直接落戶上海
Stratégie touristique d'été de Singapour: un jour pour visiter l'île de San taosha à Singapour
UML class diagram
Night God simulator +fiddler packet capture test app
Implementation shadow introduction
如何清理废弃pv和其对应的文件夹
Comprendre complètement le tutoriel de traitement de Point Cloud basé sur open3d!
UE4 用spline画正圆
Mini Golf Course: a good place for leisure and tourism in London
全链路数字化转型下,零售企业如何打开第二增长曲线
随机推荐
RTE11- 中断解耦功能
1.5.1版本官方docker镜像运行容器,能设置使用 mysql 8驱动吗?
Websocket of Web real-time communication technology
300+ documents! This article explains the latest progress of multimodal learning based on transformer
Server PHP environment building tutorial, PHP server environment building graphic explanation
Unity learning shader notes [81] simple color adjustment post-processing (brightness, saturation, contrast)
“栈”的典型应用—表达式求值(C语言实现)
Introduction to sap s/4hana OData mock service
谷歌官方回应:我们没有放弃TensorFlow,未来与JAX并肩发展
Looking for innocence in New York -- a beautiful day at the discovery center of Legoland, New Jersey
元宇宙链游系统开发(逻辑开发)丨链游系统开发(详细分析)
Matlab中弧度转角度、角度转弧度
【愚公系列】2022年07月 Go教学课程 001-Go语言前提简介
揭秘得物客服IM全链路通信过程
Hongmeng's fourth learning
昨天阿里学长写了一个责任链模式,竟然出现了无数个bug
Leetcode 面试题 17.01. 不用加号的加法
鸿蒙第四次学习
A simple PHP personal card issuing program v4.0
UML class diagram