- 博客(3)
- 收藏
- 关注
原创 彻底搞清Java字符串创建几个对象问题
老掉牙的问题,网上搜了一圈,还是没看到合理清晰的回答,决定自己记一下这个问题的理解。 首先看一下常见的代码 String s1 = "hello"; String s2 = new String("hello"); String s3 = new String("hello"); String s4 = new String("world"); 上述代码: 第一行在常量池创建了一个对象"hello",然后返回常量池中"hello"的地
2021-09-02 12:01:22
5148
8
原创 刷题C++必备
string类 需要包含头文件<string> #include <iostream> #include <string> using namespace std; int main() { //正确初始化 string s1("hello"); string month = "March"; string s2(8, 'x'); string s; s = 'n'; // 可以将字符赋值给string对象 ..
2021-08-25 16:59:09
187
原创 快速排序清晰版思路
快排的思想很简单,就是找到一个基准值,然后将原序列分成两部分,左边的部分都小于该基准值,右边的部分大于等于该基准值。但是思路虽简单,实现起来往往由于边界情况导致不容易一把bug-free过,本文简单介绍一种易于实现的代码思路。 废话不多说,先直接上代码: void swap(int* left, int* right){ int temp = *left; *left = *right; *right = temp; } int partition(int arr[], in
2021-08-07 19:24:14
156
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅