当前位置:网站首页>[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
边栏推荐
- 工业软件讲堂-三维CAD设计软件的核心技术解析----讲坛第二次讲座
- Troubleshooting: kubectl reports an error validationerror: unknown field \u00a0
- Esp32-c3 introductory tutorial question ⑩ - error: implicit declaration of function 'ESP_ blufi_ close‘;
- 材质UV遮罩的技巧
- Comprendre complètement le tutoriel de traitement de Point Cloud basé sur open3d!
- Ali was wildly asked by the interviewer on three sides. Redis dared not write 'proficient' on his resume anymore
- Leetcode 面试题 16.17. 连续数列
- Uncover the whole link communication process of dewu customer service im
- 谷歌官方回应:我们没有放弃TensorFlow,未来与JAX并肩发展
- Google's official response: we have not given up tensorflow and will develop side by side with Jax in the future
猜你喜欢
UML class diagram
距离度量 —— 杰卡德距离(Jaccard Distance)
M2dgr: slam data set of multi-source and multi scene ground robot (ICRA 2022)
Leetcode 面试题 16.11. 跳水板
Thoroughly understand the point cloud processing tutorial based on open3d!
新加坡暑假旅游攻略:一天玩转新加坡圣淘沙岛
Implementation shadow introduction
After 22 years in office, the father of PowerShell will leave Microsoft: he was demoted by Microsoft for developing PowerShell
CDN acceleration and breaking J anti-theft chain function
Night God simulator +fiddler packet capture test app
随机推荐
Détends - toi encore! Ces nouveaux étudiants peuvent s'installer directement à Shanghai
Troubleshooting: kubectl reports an error validationerror: unknown field \u00a0
Basic idea of quick sorting (easy to understand + examples) "suggestions collection"
Chain game system development (unity3d chain game development details) - chain game development mature technology source code
Meta universe chain game system development (logic development) - chain game system development (detailed analysis)
UML 类图
阿里三面被面试官狂问Redis,简历上再也不敢写'精通'了
Comprendre complètement le tutoriel de traitement de Point Cloud basé sur open3d!
How to enable the run dashboard function of idea
【愚公系列】2022年07月 Go教学课程 001-Go语言前提简介
Leetcode 面试题 16.15. 珠玑妙算
LightGroupButton* sender = static_cast<LightGroupButton*>(QObject::sender());
新加坡暑假旅游攻略:一天玩转新加坡圣淘沙岛
如何清理废弃pv和其对应的文件夹
Leetcode (154) -- find the minimum value II in the rotation sort array
昨天阿里学长写了一个责任链模式,竟然出现了无数个bug
What are the links of the problem
SLAM|如何时间戳对齐?
Web实时通信技术之Websocket
如何优雅的写 Controller 层代码?