迭代一组

编程入门 行业动态 更新时间:2024-10-28 10:26:22
本文介绍了迭代一组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

以下集合包含整数,我需要用十替换10的倍数。任何人都可以指导我正确的方向吗?如何用整数替换字符串。

The following set contains integer, I need to replace any number which is multiple of 10 by "ten". Can anyone guide me in the right direction please?? How can I replace strings by integers.

descendingOrder=(TreeSet<Integer>)sortedSet.descendingSet(); System.out.println("The sorted list is:"); System.out.println(descendingOrder);

推荐答案

您不能直接用不同的类型替换类型。但是(如果我正确理解你的问题),在打印列表时,你只需要检查每个值以查看它是否是10的倍数,如果是,则打印一些字符串信息而不是值。 You cannot directly replace a type by a different type. However (if I understand your question correctly), while printing the list, you just need to check each value to see if it is a multiple of 10, and if so print some string information instead of the value.

更多推荐

迭代一组

本文发布于:2023-11-10 03:23:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1574222.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:迭代

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!