当前位置: 首页 > news >正文

7.15 Java基础|大小写转换、数组、ArrayList类

目录

一、大小写转换:

        法一:函数法 

        法二:异或转换

 二、数组

1、数组声明

2、数组创建

3、For-Each循环来遍历数组

4、作为函数参数

5、作为函数返回值

三、ArrayList数组列表

明天继续......


一、大小写转换:

        法一:函数法 

        法二:异或转换

package day715;
/*注意:* 1、是String类下的 toLowerCase()和toUpperCase();* 2、*/
public class 大小写转换 {public static void main(String[] args) {
//法一:	函数法	String a=new String("SdaASFNvadfA/123??sdfaklKJJ");a=a.toLowerCase();System.out.println(a);a=a.toUpperCase();System.out.println(a);
//法二:异或转化//char x='a'^32;/**异或 32 能实现大小写转换的核心原因是:** ASCII 编码中,大小写字母的二进制表示仅在第 6 位不同。* 异或 32(二进制00100000)恰好可以翻转第 6 位,从而切换大小写状态。* */System.out.println('a'^32);}
}

 二、数组

1、数组声明

一维数组:

int[] name;//首选 定义一个整数类型的数组,名字是name
int name[];//主要为了方便c、c++学员快速理解和使用

 二维数组:

String[][] str =new String[3][4];
2、数组创建
int[] a=new int[8];//整数型数组a,大小为8
double[] b={1.2,2.2,3.3,4.4};
3、For-Each循环来遍历数组
for(double element:b){System.out.println(element);
}
4、作为函数参数
//-----   定义  ------------
public static void fun(int[] array){//具体操作
}//------  调用   -------------
fun(new int[]{3,2,1,24,4});
5、作为函数返回值
public static int[] reverse(int[] list){int[] result=new int[list.length];//存储结果//处理//......return result;
}

三、ArrayList数组列表

ArrayList打破普通数组需要先声明数组的规则,可以自动调整他的容量,因此,数组列表也称为动态数组。

1、创建数组:

   ArrayList<Type> name=new ArrayList<>();

如:

ArrayList<Integer> name=new ArrayList<>();整数类型动态数组

ArrayList<String> name =new ArrayList<>();字符类型动态数组

还可以使用List接口创建ArrayList:

List<String> list=new ArrayList<>();

 2、ArrayList的方法

(1)add(Object element)列表尾部添加指定元素

(2)size() 返回列表元素个数

(3)get(int index) 返回列表中指定位置的元素

(4)isEmpty();

  (5)contains(Object o);

(6)remove(int index);

明天继续......


文章转载自:
http://bedstone.dmyyro.cn
http://calamus.dmyyro.cn
http://cesium.dmyyro.cn
http://appropriation.dmyyro.cn
http://astrict.dmyyro.cn
http://bacterioid.dmyyro.cn
http://bucentaur.dmyyro.cn
http://arson.dmyyro.cn
http://bluenose.dmyyro.cn
http://broadcasting.dmyyro.cn
http://burnouse.dmyyro.cn
http://asphaltum.dmyyro.cn
http://chamberer.dmyyro.cn
http://blithering.dmyyro.cn
http://atm.dmyyro.cn
http://cherrywood.dmyyro.cn
http://butyl.dmyyro.cn
http://artificial.dmyyro.cn
http://acetify.dmyyro.cn
http://brainpower.dmyyro.cn
http://baroness.dmyyro.cn
http://brynhild.dmyyro.cn
http://babi.dmyyro.cn
http://caddis.dmyyro.cn
http://barebacked.dmyyro.cn
http://adiaphorist.dmyyro.cn
http://chromascope.dmyyro.cn
http://brucella.dmyyro.cn
http://busybody.dmyyro.cn
http://article.dmyyro.cn
http://www.dtcms.com/a/280401.html

相关文章:

  • 基于Langchain4j开发AI编程助手
  • Python_1
  • 高等数学强化——导学
  • 【Python练习】044. 编写一个函数,实现快速排序算法
  • 第十三讲 | map和set的使用
  • JavaDemo——使用CGLIB动态代理
  • I3C通信驱动开发注意事项
  • 【雅思播客016】New Year Resolution 新年决心
  • docker搭建freeswitch实现点对点视频,多人视频
  • 极致cms多语言建站|设置主站默认语言与设置后台固定语言为中文
  • 嵌入式学习-PyTorch(4)-day21
  • 多相机depth-rgb图组完整性分拣器_MATLAB实现
  • @[TOC](模拟) # 1.替换所有的问号(easy)
  • 学C++做游戏,先搞懂这些基础要点
  • 《大数据技术原理与应用》实验报告六 Flink编程实践
  • 使用JS编写用户信息采集表单
  • 【Python3-Django】快速掌握DRF:ModelViewSet实战指南
  • OneCode 3.0 从0到1干货——AIGC及MCP注解驱动开发物联网AI决策应用
  • 全新 Python 项目托管到 Gitee 私有仓库完整流程(带详细命令注释)
  • OpenVINO initialization error: Failed to find plugins.xml file
  • uv 使用指导文档
  • 【机器学习深度学习】LoRA 微调详解:大模型时代的高效适配利器
  • BlueLotus XSS管理后台使用指南
  • GeoTools 工厂设计模式
  • 传输协议和消息队列
  • AR眼镜:重塑医学教育,开启智能教学新时代
  • 同步辐射XAFS和XRD协同用于高熵合金的研究应用
  • 香港站群服务器租用:为什么需要选择不同C类IP?
  • python的广东省家庭旅游接待信息管理系统
  • k8s之Attach 和 Mount