
Java
Java语言学习
不合格码农
这个作者很懒,什么都没留下…
展开
-
Java 对字符串中字符进行自然顺序排序
背景:在对业务数据进行处理时,有对某一字符串进行排序处理,方式如下:@Test public void strSort() { String str = "abc123abcde123dbeabced"; String targetStr = ""; //用来接收排序后的字符串 char[] arrays = new char[str.length()];//声明字符数组,用来接收str转换成char的结果 //将str字符串转换原创 2021-11-03 13:25:55 · 375 阅读 · 0 评论 -
Java System.out.printf()使用详解
public class PrintfTest { public static void main(String[] args) { // 定义一些变量,用来格式化输出。 double d = 345.678; String s = "你好!"; int i = 1234; // "%"表示进行格式化输出,"%"之后的内容为格式的定义。 System.out.printf("%f", d);// "f".原创 2021-10-25 21:53:28 · 2263 阅读 · 0 评论 -
取模运算%
取模运算通用公式:x-x/b*b举例(除不尽取整数部分):10%3的结果为1:带入公式得:10 - 10 / 3 * 3 = 1-10%3的结果为-1:带入公式得:-10 - (-10) / 3 * 3 = -1-10%-3的结果为-1:带入公式得:-10 - (-10) / -3 * (-3) = -1...原创 2021-09-30 15:53:03 · 872 阅读 · 0 评论 -
Java代码文件复制方法比较
import java.io.*;public class CopyFile{ //文件复制功能封装为方法public void copyFile(String srcPath,String destPath){ FileInputStream fis = null; FileOutputStream fos = null; try { //1.创建File类对象 File srcFile = new File(srcPa...原创 2021-09-22 22:05:15 · 236 阅读 · 0 评论