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

做网站要多少费用设计小程序多少钱

做网站要多少费用,设计小程序多少钱,网站备案链接代码,万网域名申请网站如果您有两个不同的类#xff0c;但它们拥有相同的属性#xff0c;并且您想要从一个类的列表复制到另一个类的列表#xff0c;您可以使用以下方法#xff1a; 使用循环#xff1a; 您可以遍历原始列表#xff0c;并为每个元素创建目标类的新实例。 使用 Stream API…如果您有两个不同的类但它们拥有相同的属性并且您想要从一个类的列表复制到另一个类的列表您可以使用以下方法 使用循环 您可以遍历原始列表并为每个元素创建目标类的新实例。 使用 Stream API 如果您使用的是 Java 8 或更高版本您可以利用 Stream API 来简化这个过程。 下面是一个具体的例子假设您有两个类 SourceItem 和 TargetItem它们都有相同的属性 name 和 value。 示例代码 import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors;// 原始类 class SourceItem {private String name;private int value;public SourceItem(String name, int value) {this.name name;this.value value;}public String getName() {return name;}public int getValue() {return value;} }// 目标类 class TargetItem {private String name;private int value;public TargetItem(String name, int value) {this.name name;this.value value;}public String getName() {return name;}public int getValue() {return value;} }public class ListCopyExample {public static void main(String[] args) {ListSourceItem sourceList new ArrayList();sourceList.add(new SourceItem(Item 1, 100));sourceList.add(new SourceItem(Item 2, 200));// 使用 Stream API 复制列表ListTargetItem targetList sourceList.stream().map(source - new TargetItem(source.getName(), source.getValue())).collect(Collectors.toList());System.out.println(Original List: sourceList);System.out.println(Copied List: targetList);} }在这个例子中我们使用了 Stream API 的 map 方法来转换每个 SourceItem 成为 TargetItem。如果您更喜欢使用传统的循环方式可以使用以下代码 import java.util.ArrayList; import java.util.List;class SourceItem {private String name;private int value;public SourceItem(String name, int value) {this.name name;this.value value;}public String getName() {return name;}public int getValue() {return value;} }class TargetItem {private String name;private int value;public TargetItem(String name, int value) {this.name name;this.value value;}public String getName() {return name;}public int getValue() {return value;} }public class ListCopyExample {public static void main(String[] args) {ListSourceItem sourceList new ArrayList();sourceList.add(new SourceItem(Item 1, 100));sourceList.add(new SourceItem(Item 2, 200));// 使用循环复制列表ListTargetItem targetList new ArrayList();for (SourceItem sourceItem : sourceList) {TargetItem targetItem new TargetItem(sourceItem.getName(), sourceItem.getValue());targetList.add(targetItem);}System.out.println(Original List: sourceList);System.out.println(Copied List: targetList);} }这两种方法都可以有效地完成任务。使用哪种方法取决于您的个人偏好以及项目的需求。
http://www.hkea.cn/news/14302749/

相关文章:

  • 在线咨询 1 网站宣传用vue-cli做的网站
  • 网站设计下载wordpress 5.0.4
  • 做企业网站哪家好结合实际
  • 女生做网站主题有哪些wordpress如何返回之前更新的版本
  • 深圳做网站可用乐云seo十年学校建设网站重要性
  • 北京专业设计网站重庆网站制作有哪些
  • 网站建设公司巨头网站设计一般包括什么
  • 企业建站怎么选择做网站学费多少钱
  • 开发网站能赚多少钱wordpress 修改搜索引擎
  • 只做网站不推广能行吗哪个网站开发小程序
  • 有了域名如何建立网站烟台网站建设方案托管
  • 星月教你做网站的文档一个提高网站流量的常用方法
  • 网站建设与管理出来工资zencart网站搬家
  • 如何购物网站建设十堰论坛网站
  • vs2008 手机网站开发湖州市南浔区建设局网站
  • 包头住房与城乡建设局网站杭州企业网站建设公司怎么样
  • 内蒙古住房和城乡建设网站设计师应该知道的网站
  • 好网站建设公司企业网站怎么做的更好
  • 什么网站可免费发布信息局域网站怎么做
  • 广元城乡建设部网站首页广州专业网页制作
  • 用凡科做的网站怎么下载ui设计去什么公司好
  • 在阿里云域名可以做网站吗wordpress 书签
  • 门户网站样式移动端网页制作流程
  • 珠海手机网站建设如何做公司简介介绍
  • 电子政务网站建设要求为什么做视频网站违法
  • 七牛云建网站做网站哪家公司比较好而且不贵
  • 商超运营与管理优化网络搜索引擎
  • 建设银行温州分行网站域名备案期间怎么做网站
  • 建设网站应该注意的地方响应式网站如何做的
  • 汽车网站首页模板代码网站建设 移动端 和 PC端