java对double数组排序示例分享
时间:2022-07-13 03:22:14
package airthmatic;
public class demo10 {
public static void main(String[] args) {
double n[]={9,1.2,5,3.2,1.1};
orderNum(n);
}
/**
* double 和 int 数字排序
* @param n
*/
public static void orderNum(double []n){
for(int i=0;i<n.length-1;i++){
for(int j=0;j<n.length-1-i;j++){
double temp=0;
if(n[j]>n[j+1]){
temp=n[j+1];
n[j+1]=n[j];
n[j]=temp;
}
}
}
/**
* 这里是过滤掉整数的double类型
*/
for(int i=0;i<n.length;i++){
int temp=(int)n[i];
if(n[i]%temp==0){
System.out.println(temp);
}else{
System.out.println(n[i]);
}
}
}
}
标签:java,double,数组
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
MyBatis逆向工程基本操作及代码实例
2022-12-19 04:09:27
详解如何将JAR包发布到Maven中央仓库
2023-02-14 07:26:00
![](https://img.aspxhome.com/file/2023/9/84769_0s.png)
详解Java目录操作与文件操作教程
2023-12-05 13:45:48
![](https://img.aspxhome.com/file/2023/7/58887_0s.png)
基于java SSM springboot实现抗疫物质信息管理系统
2021-12-01 13:46:34
![](https://img.aspxhome.com/file/2023/2/72312_0s.png)
使用java技术抓取网站上彩票双色球信息详解
2022-01-04 14:47:51
![](https://img.aspxhome.com/file/2023/1/60111_0s.jpg)
C#实现密码验证与输错密码账户锁定
2022-04-05 13:22:22
C#操作注册表的方法
2022-04-14 03:20:36
Java执行cmd命令两种实现方法解析
2022-09-24 02:43:49
SpringBoot整合Shiro实现登录认证的方法
2022-03-23 01:12:19
![](https://img.aspxhome.com/file/2023/5/64755_0s.png)
OpenCV实现直线检测并消除
2023-07-12 20:44:36
![](https://img.aspxhome.com/file/2023/3/92493_0s.jpg)
Android实现跑马灯效果的方法
2021-09-06 13:56:38
![](https://img.aspxhome.com/file/2023/3/87303_0s.jpg)
Android 网络请求框架Volley实例详解
2023-08-11 07:00:18
![](https://img.aspxhome.com/file/2023/7/139487_0s.gif)
Android操作存放在assets文件夹下SQLite数据库的方法
2023-12-13 21:00:26
spring profile 多环境配置管理详解
2023-01-23 17:53:58
Android实现将应用崩溃信息发送给开发者并重启应用的方法
2021-07-25 02:42:14
![](https://img.aspxhome.com/file/2023/5/88105_0s.gif)
详谈Springfox与swagger的整合使用
2021-11-25 21:08:34
![](https://img.aspxhome.com/file/2023/5/77405_0s.png)
Java内存模型与JVM运行时数据区的区别详解
2023-11-24 13:29:08
详解Maven profile配置管理及激活profile的几种方式
2022-07-01 08:54:46
SpringBoot过滤器与拦截器使用方法深入分析
2023-08-18 10:20:03
![](https://img.aspxhome.com/file/2023/3/84643_0s.png)
Java KeyGenerator.generateKey的19个方法代码示例
2022-08-08 14:26:40