【java8】请问一个ArrayList使用stream的map后,会保证原有顺序吗?

如题

List users = xxxxxxx;

假设User里面有3个数据,“a”“b”“c”

我使用users.stream().map....................toList

后,请问顺序还是abc么

7个回答

                //顺序不变
        List collect = users.stream().map(String::toUpperCase).collect(Collectors.toList());

                //顺序会变
                List collect = users.parallelStream().map(String::toUpperCase).collect(Collectors.toList());

是和否的问题,还是建议你直接代码运行试下就确定了,这样有助于你的学习

对于有顺序的源数据,比如list,set,Stream操作之后仍然会按照顺序排(线性操作)。
如果是非固定顺序的数据源,则不保证其最后处理的顺序。
对于线性Streams,源的固定顺序对性能没有特别影响。
对于并行Streams,不强调顺序的话显然性能会更好。比如filter,distinct,groupingBy操作,非顺序操作的效率就更好,可参考博客
另外,如果数据本身是固定顺序的,但是开发者本身不在意是否按顺序处理,那么可以通过unordered()处理之后再操作,会提高某些有状态的并行操作和结束操作的效率。

顺序不变。可以运行此代码。
List users=Arrays.asList("x","b","c");
for(int i=0;i System.out.println(users.get(i));
}
List collect = users.stream().map(String::toUpperCase).collect(Collectors.toList());
for(int i=0;i<collect.size();i++){
System.out.println(collect.get(i));
}
结果为 x b c, X B C

ArrayList使用stream的map后,会保证原有顺序的,除非你添加了优先级或者插入数据

使用stream是顺序流 他是不会变化的除非你在后续操作中做了修改

使用users.stream()......顺序不会发生改变

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
如何使用Lambda表达式对Map进行分组?

有如下数据 我想对该数据进行分组(按camp阵营进行分组) 但是我不知道该怎么写,求大神指教 ``` package com.renguanyu.demo.lambda; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class Data { public static List<Map<String,Object>> getSanGuoMaps(){ List<Map<String,Object>> maps = new ArrayList<>(); Map<String,Object> map1 = new HashMap<>(); map1.put("id", 1); map1.put("name", "刘备"); map1.put("height", 175.01); map1.put("camp", "蜀"); Map<String,Object> map2 = new HashMap<>(); map2.put("id", 2); map2.put("name", "关羽"); map2.put("height", 180.00); map2.put("camp", "蜀"); Map<String,Object> map3 = new HashMap<>(); map3.put("id", 3); map3.put("name", "张飞"); map3.put("height", 190.00); map3.put("camp", "蜀"); Map<String,Object> map4 = new HashMap<>(); map4.put("id", 4); map4.put("name", "吕布"); map4.put("height", 190.00); map4.put("camp", "其他"); maps.add(map1); maps.add(map2); maps.add(map3); maps.add(map4); return maps; } } ``` ``` package com.renguanyu.demo.lambda; import java.util.List; import java.util.Map; import java.util.stream.Collectors; public class Demo1 { public static void main(String[] args) { List<Map<String, Object>> sanGuoMaps = Data.getSanGuoMaps(); System.out.println(sanGuoMaps); // sanGuoMaps.stream().collect(Collectors.groupingBy(Map::get("name"))); } } ```

java8Stream流使用方式

![图片说明](https://img-ask.csdn.net/upload/201905/17/1558083974_301810.png) 问题如图 1:写上了数据结构,可直接写, 2:要用stream 流实现 ``` public void testTest(){ Map<String,String> objectObjectHashMap = new HashMap<>(); objectObjectHashMap.put("id","1"); objectObjectHashMap.put("contract_id","1"); objectObjectHashMap.put("repay_at","65"); objectObjectHashMap.put("plan_total_price","36"); Map<String,String> objectObjectHashMap1 = new HashMap<>(); objectObjectHashMap.put("id","6"); objectObjectHashMap.put("contract_id","1"); objectObjectHashMap.put("repay_at","98"); objectObjectHashMap.put("plan_total_price","54"); Map<String,String> objectObjectHashMap2 = new HashMap<>(); objectObjectHashMap.put("id","44"); objectObjectHashMap.put("contract_id","2"); objectObjectHashMap.put("repay_at","87"); objectObjectHashMap.put("plan_total_price","36"); Map<String,String> objectObjectHashMap3 = new HashMap<>(); objectObjectHashMap.put("id","8"); objectObjectHashMap.put("contract_id","2"); objectObjectHashMap.put("repay_at","35"); objectObjectHashMap.put("plan_total_price","21"); List<Map<String,String>> list = new ArrayList<>(); list.add(objectObjectHashMap); list.add(objectObjectHashMap1); list.add(objectObjectHashMap2); list.add(objectObjectHashMap3); } ```

如何使用Java8Lambda表达式对两个List<Object>中的多个元素进行对比筛选

``` List<Student> list = new ArrayList<>(); List<Student> list2 = new ArrayList<>(); Student student1 = new Student(); student1.setAge("一"); student1.setSex(1); Student student2 = new Student(); student2.setAge("一"); student2.setSex(2); Student student3 = new Student(); student3.setAge("三"); student3.setSex(3); Student student4 = new Student(); student4.setAge("四"); student4.setSex(4); // List2 Student student5 = new Student(); student5.setAge("一"); student5.setSex(1); Student student6 = new Student(); student6.setAge("二"); student6.setSex(9); Student student7 = new Student(); student7.setAge("三"); student7.setSex(9); Student student8 = new Student(); student8.setAge("四"); student8.setSex(9); ``` 现在想要的结果是筛选出两个List中age,sex都一样的元素组成一个新List<Student> ``` Set<Student> s = list.stream() .map( user -> list2.stream() .filter(log -> user.getAge().equals(log.getAge())) .filter(log -> user.getSex() == log.getSex()) .findAny() .orElse(user) ) .collect(Collectors.toSet()); ``` 我自己试了下好像并没有卵用

list转换成map错误:java.lang.String cannot be cast to j

我想把类似[{name=小明, age=18}, {name=小红, age=20}, {name=大熊, age=17}]这样从 数据库取出来的list转换成[小明,18,小红,20,大熊,17](String类型list。 项目中这段代码是这样实现的 ``` public List executeSQL(String sql){ log.debug(sql); List<String> aList = new ArrayList(); List jlist = jdbcTemplate.queryForList(sql); for(int i=0;i<jlist.size();i++){ System.out.println(jlist.get(i).getClass()); } Iterator ite = jlist.iterator(); while(ite.hasNext()){ Map map = (Map)ite.next(); for(Object o:map.keySet()){ if(map.get(o.toString())==null){ aList.add(""); }else{ aList.add(map.get(o.toString()).toString()); } } } return aList; } ``` 我自己写了简单的想实现下 ``` public class mapDemo { public static void main(String[] args) { List<String> a = new ArrayList(); List b = new ArrayList<>(); String c1 = new String("{name=小明, age=18}"); String c2 = new String("{name=小红, age=20}"); String c3 = new String("{name=大熊, age=17}"); b.add(c1); b.add(c2); b.add(c3); Iterator it =b.iterator(); while(it.hasNext()){ Map map = (Map)it.next(); for(Object o:map.keySet()){ if(map.get(o.toString())==null){ a.add(""); }else{ a.add(map.get(o.toString()).toString()); } } } } } ``` 但是提示错误:java.lang.String cannot be cast to java.util.Map 数据库取出来的list和我add进去的有什么不一样吗,我这段是哪里错了?

Collectors.groupingBy 如何对 List<Map<String,Object>>集合分组

``` //网上对groupingBy的使用都是针对类对象的分组例子,如List<Person>、List<Student>这种。 //可是我这里有如下数据,应该怎么弄呢? List<Map<String,Object>> list = new ArrayList<>(); Map<String,Object> map = new HashMap<>(); map.put("dicId","aaa"); map.put("dicName","钢材"); map.put("dicDes","钢材1号"); list.add(map); map = new HashMap<>(); map.put("dicId","bbb"); map.put("dicName","钢筋"); map.put("dicDes","钢筋1号"); list.add(map); map = new HashMap<>(); map.put("dicId","111"); map.put("dicName","钢筋"); map.put("dicDes","钢筋2号"); list.add(map); map = new HashMap<>(); map.put("dicId","ccc"); map.put("dicName","河沙"); map.put("dicDes","河沙1号"); list.add(map); //比如以dicId分组成为Map<String, List<Map<String,Object>>> ```

List<Object>转map问题 来大牛解答 或者来同行交流

List<Object> cfd = this.findCfd(jzid,cfid,kind,token); 现在要取出里面的某一个元素 开始做法 直接转map 然后Integer mrjs = (Integer) brfymxmap.get("mrjs"); 就可以取出mrjs这个属性 但是转成map后就没有值了 现在的做法是 Map<String , List<Object>> cfdmap = new HashMap<String , List<Object>>(); cfdmap.put("cfd", cfd); for (String cfdjihe : cfdmap.keySet()) { List<Object> lisMap = new ArrayList<Object>(); lisMap = cfdmap.get(cfdjihe); for (int i = 0 ; i< lisMap.size() ; i++){ System.out.println("取出List中VALUE的第" + "[" +(i+1)+"]个值:"+ lisMap.get(i).toString()); } } 输出的格式 取出List中VALUE的第[1]个值:[{dybz=1, cymrcs=0, cfdh=CFDH20190331194130602, cflbid=1, jlzt=1, cfid=1, jzysid=375, sqdh=null, bz=null, jzksid=445, jzid=19, sqdlx=null, cfdid=null, ylfwjgid=1, dyrid=2, sqtm=null, cyzjs=null, kind=1, cymrjs=0, sqdid=0, cyfysm=null, kdrq=2019-05-11 09:17:07,}]分割 是能取出我要的值 麻烦 但是只适合我这个场景的 因为我list就只有一条数据

求java代码,关于两个list数组比较的,并且把不同的部分输出打印

如何比较两个list数组,并且把不同的部分输出打印 第一个数组,是从数据库中查到的:while(rs.next()){ nsrsbhName.put(rs.getString("b"),rs.getString("a")); } nsrsbhList.add(nsrsbhName); //将map内容放入到list中 for (Map<String, String> m : nsrsbhList){ for (String k : m.keySet()) { System.out.println(k + " " + m.get(k)); } } 显示的效果是:12201 济南 12202 青岛 第二个数组是自己定义的: String[] arr={"12201","12202","12203","12204","12205","12206","12207","12208","12209","12210","12211","12212","12213","12214","12215","12216","12217"}; 比较这两个数组,将不同的部分输出打印

后台返回数据问题。。 List<Map<String,Object>>

![图片说明](https://img-ask.csdn.net/upload/201703/01/1488337180_394359.png) 前台接收的是这种格式的。![图片说明](https://img-ask.csdn.net/upload/201703/01/1488336944_198710.png) ![图片说明](https://img-ask.csdn.net/upload/201703/01/1488336954_381928.png) 我应该怎么赋值到id上啊?

一下代码怎么提示找不到符号

import java.util.*; public class lianxi9 { public static void main(String[] args) { Collection<Integer> c1 = new ArrayList<Integer>(); Collection<Integer> c2 = new HashSet<Integer>(); Random random = new Random(); for(int i =0;i<15;i++) { c1.add(random.nextInt(20)); c2.add(random.nextInt(20)); } for(int i=0;i<5;i++) { System.out.println(c1.get(i));//此处报错 System.out.println(c2.get(i));//此处报错 } } }

springboot报错java.lang.NoClassDefFoundError

报错信息 ``` java.lang.NoClassDefFoundError: Could not initialize class sun.security.ssl.SSLSessionImpl at sun.security.ssl.SSLSocketImpl.init(SSLSocketImpl.java:598) at sun.security.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:566) at sun.security.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:110) at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:365) at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:355) at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142) at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373) at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381) at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237) at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185) at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111) at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) at com.ii.shenfu.destroyer.core.service.impl.FileServiceImpl.testStampSignature(FileServiceImpl.java:222) at com.ii.shenfu.destroyer.core.service.impl.FileServiceImpl.upload(FileServiceImpl.java:139) at com.ii.shenfu.destroyer.core.service.impl.FileServiceImpl.buildPdfContentToOss(FileServiceImpl.java:173) at com.ii.shenfu.destroyer.core.service.impl.FileServiceImpl$$FastClassBySpringCGLIB$$d052386c.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88) at com.ii.shenfu.destroyer.api.monitor.SysMonitorAspect.monitorExeTime(SysMonitorAspect.java:42) at sun.reflect.GeneratedMethodAccessor92.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633) at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688) at com.ii.shenfu.destroyer.core.service.impl.FileServiceImpl$$EnhancerBySpringCGLIB$$cad23556.buildPdfContentToOss(<generated>) at com.ii.shenfu.destroyer.core.service.impl.ReconsiderApprovalServiceImpl.lambda$fillPdfId$7(ReconsiderApprovalServiceImpl.java:417) at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) at com.ii.shenfu.destroyer.core.service.impl.ReconsiderApprovalServiceImpl.fillPdfId(ReconsiderApprovalServiceImpl.java:414) at com.ii.shenfu.destroyer.core.service.impl.ReconsiderApprovalServiceImpl.submit(ReconsiderApprovalServiceImpl.java:267) at com.ii.shenfu.destroyer.core.service.impl.ReconsiderApprovalServiceImpl$$FastClassBySpringCGLIB$$781cc779.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88) at com.ii.shenfu.destroyer.api.monitor.SysMonitorAspect.monitorExeTime(SysMonitorAspect.java:42) at sun.reflect.GeneratedMethodAccessor92.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633) at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688) at com.ii.shenfu.destroyer.core.service.impl.ReconsiderApprovalServiceImpl$$EnhancerBySpringCGLIB$$d0a9329d.submit(<generated>) at com.ii.shenfu.destroyer.api.controller.admin.ReconsiderApprovalController.submit(ReconsiderApprovalController.java:29) at com.ii.shenfu.destroyer.api.controller.admin.ReconsiderApprovalController$$FastClassBySpringCGLIB$$c73d6e1.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88) at com.ii.shenfu.destroyer.api.monitor.SysMonitorAspect.monitorExeTime(SysMonitorAspect.java:42) at sun.reflect.GeneratedMethodAccessor92.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633) at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688) at com.ii.shenfu.destroyer.api.controller.admin.ReconsiderApprovalController$$EnhancerBySpringCGLIB$$db9ad95c.submit(<generated>) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:877) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:783) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:877) at javax.servlet.http.HttpServlet.service(HttpServlet.java:661) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851) at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at com.ii.shenfu.destroyer.core.web.filter.RequestWrapperFilter.doFilter(RequestWrapperFilter.java:29) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:96) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.session.web.http.SessionRepositoryFilter.doFilterInternal(SessionRepositoryFilter.java:147) at org.springframework.session.web.http.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:81) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1468) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) ``` 在本地运行没有问题 但放在服务器上就报了这个错误 在网上找的方法都是将jdk的版本降低 但是我本地的是1.8.0-152 网上说的是将jdk版本降低到1.8.0-151 请问一下大佬是什么原因才出现的这种问题 真心的搞不懂

list和map在普通情况下哪个取数据快?

list {key:'asdf',attr:234},{key:'asdf',attr:234} map 'asdf':{attr:234},'asdf':{attr:234} 有一堆这些数据 在取某一项的时候 那个快点? 我看map在取的时候实际也是在遍历 固定顺序下应该是list快点? 也就是 arraylist 和 linkedhashmap对比

java 动态依据不特定字段进行分组和统计

写了动态指定单个字段的分组,但是 MethodHandle handle = lookup.findGetter(this.getT().getClass(), fieldName, String.class); 会报错找不到字段,我确定字段没写错 ``` public class CollectionsUtils<T> { private T t; public T getT() { return t; } public void setT(T t) { this.t = t; } public CollectionsUtils(T t) { this.t = t; } //多字段排序 public <T> Map<List<String>, List<T>> DynamicGroupListByFiled(List<T> data, String[] groupByFieldNames) { final MethodHandles.Lookup lookup = MethodHandles.lookup(); List<MethodHandle> handles = Arrays.stream(groupByFieldNames) .map(field -> { try { return lookup.findGetter(this.getT().getClass(), field, String.class); } catch (Exception e) { throw new RuntimeException(e); } }).collect(Collectors.toList()); return data.stream().collect(Collectors.groupingBy( d -> handles.stream() .map(handle -> { try { return (String) handle.invokeExact(d); } catch (Throwable e) { throw new RuntimeException(e); } }).collect(Collectors.toList()) )); } //按某字段分组后统计数量 public Map<String, Long> DynamicGroupListByFiled(List<T> data, String fieldName) { final MethodHandles.Lookup lookup = MethodHandles.lookup(); try { MethodHandle handle = lookup.findGetter(this.getT().getClass(), fieldName, String.class); return data.stream().collect(Collectors.groupingBy( d -> { try { return (String) handle.invokeExact(d); } catch (Throwable e) { throw new RuntimeException(e); } } ,Collectors.counting())); } catch (Throwable e) { throw new RuntimeException(); } } //算不定字段平均值 public Double getDynamicFieldAverage(List<T> data, String fieldName) { final MethodHandles.Lookup lookup = MethodHandles.lookup(); try { MethodHandle handle = lookup.findGetter(this.getT().getClass(), fieldName, String.class); return data.stream().mapToDouble(d -> { try { return (Double) handle.invokeExact(d); } catch (Throwable e) { throw new RuntimeException(e); } } ).average().getAsDouble(); } catch (Exception e) { throw new RuntimeException(e); } } } @Test public void testCollectionUtils() { List<EsFitnessTestRecordDO> list = new ArrayList<>(); list.add(new EsFitnessTestRecordDO().setBmiRating("优秀").setBmiScore(90D)); list.add(new EsFitnessTestRecordDO().setBmiRating("优秀").setBmiScore(92D)); list.add(new EsFitnessTestRecordDO().setBmiRating("优秀").setBmiScore(94D)); list.add(new EsFitnessTestRecordDO().setBmiRating("良好").setBmiScore(80D)); list.add(new EsFitnessTestRecordDO().setBmiRating("良好").setBmiScore(82D)); list.add(new EsFitnessTestRecordDO().setBmiRating("良好").setBmiScore(84D)); list.add(new EsFitnessTestRecordDO().setBmiRating("合格").setBmiScore(70D)); list.add(new EsFitnessTestRecordDO().setBmiRating("合格").setBmiScore(76D)); list.add(new EsFitnessTestRecordDO().setBmiRating("不合格").setBmiScore(50D)); list.add(new EsFitnessTestRecordDO().setBmiRating("不合格").setBmiScore(40D)); list.add(new EsFitnessTestRecordDO().setBmiRating("不合格").setBmiScore(30D)); CollectionsUtils<EsFitnessTestRecordDO> ct = new CollectionsUtils(EsFitnessTestRecordDO.class); //统计bmiRating字段 优秀、良好、合格、不合格的各自人数,bmiRating是传递的参数 Map<String, Long> map = ct.DynamicGroupListByFiled(list,"bmiRating"); //计算bmiScore字段的平均值,bmiScore是传递的动态参数 double bmiAverage = ct.getDynamicFieldAverage(list,"bmiScore"); } ``` ![类的字段](https://img-ask.csdn.net/upload/201810/31/1540949963_127506.png) 调试bug图 ![BUG](https://img-ask.csdn.net/upload/201810/31/1540947738_269708.png)

JAVA输出流中的数据怎么存到集合中

创建一个学生类 使用ArrayList赋值属性然后通过InputStream存到一个txt文档里,输出流的时候怎样才能吧数据还原成一个类存到集合里面遍历查找呢

java的类型转换报错,显示类型不匹配

``` package com.example.weather; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.net.HttpURLConnection; import java.net.URL; import java.util.Map; import java.util.jar.Attributes; /** * 网络访问工具类 * @author silk * */ public class PostGet { /** * get方法直接调用post方法 * @param url 网络地址 * @return 返回网络数据 */ public static String get(String url){ return post(url,null); } /** * 设定post方法获取网络资源,如果参数为null,实际上设定为get方法 * @param url 网络地址 * @param param 请求参数键值对 * @return 返回读取数据 */ public static String post(String url,Map param){ HttpURLConnection conn=null; try { URL u=new URL(url); conn=(HttpURLConnection) u.openConnection(); //返回一个 URLConnection 对象,它表示到 URL 所引用的远程对象的连接。 StringBuffer sb = null; if(param!=null){//如果请求参数不为空 sb=new StringBuffer(); /*A URL connection can be used for input and/or output. Set the DoOutput * flag to true if you intend to use the URL connection for output, * false if not. The default is false.*/ //默认为false,post方法需要写入参数,设定true conn.setDoOutput(true); //URL 连接可用于输入和/或输出。如果打算使用 URL 连接进行输出, //则将 DoOutput 标志设置为 true;如果不打算使用,则设置为 false。默认值为 false。 //设定post方法,默认get conn.setRequestMethod("POST"); //获得输出流 OutputStream out=conn.getOutputStream(); //对输出流封装成高级输出流 BufferedWriter writer=new BufferedWriter(new OutputStreamWriter(out)); //将参数封装成键值对的形式 for(Map.Entry s:param.entrySet()){ sb.append(s.getKey()).append("=").append(s.getValue()).append("&"); } //将参数通过输出流写入 writer.write(sb.deleteCharAt(sb.toString().length()-1).toString()); writer.close();//一定要关闭,不然可能出现参数不全的错误 sb=null; } conn.connect();//建立连接 sb=new StringBuffer(); //获取连接状态码 int recode=conn.getResponseCode(); BufferedReader reader=null; if(recode==200){ //Returns an input stream that reads from this open connection //从连接中获取输入流 InputStream in=conn.getInputStream(); //对输入流进行封装 reader=new BufferedReader(new InputStreamReader(in)); String str=null; sb=new StringBuffer(); //从输入流中读取数据 while((str=reader.readLine())!=null){ sb.append(str).append(System.getProperty("line.separator")); } //关闭输入流 reader.close(); if (sb.toString().length() == 0) { return null; } return sb.toString().substring(0, sb.toString().length() - System.getProperty("line.separator").length()); } } catch (Exception e) { e.printStackTrace(); return null; }finally{ if(conn!=null)//关闭连接 conn.disconnect(); } return null; } } ``` 隔空的for循环行报错:类型不匹配:不能从元素类型 Object 转换为 Map.Entry 不知如何解决 以及为何会报错。望解惑 万分感谢!

java无法对多个excel打包下载?

java实现多个excel 打包下载,我先创建了一个临时文件夹,然后进行打包下载,最后删除这个临时文件夹, 但是没反应也不报错,求大神指教 ``` @RequestMapping(value = "downloadPreHomeWorkZIP") public void downloadLetterZIP(trainTraineeWorkModel query, HttpServletResponse response, HttpServletRequest request) throws IOException, SQLException { String serverPath =request.getSession().getServletContext().getRealPath("/")+"\\upload\\tempExcel"; List<File> srcfile=new ArrayList<File>(); //在服务器端创建文件夹 File file = new File(serverPath); if(!file.exists()){ file.mkdir(); } List<Map> employees = employeeService //查询学员上传的课前课后作业 .getMapTraineesBySessionId(1406940); if(employees.size()!=0){ for (Map map : employees) { BLOB blob = (BLOB) map.get("BEFORECLASS_WORK"); if(blob!=null&&blob.length()!=0){ String employeeCode=(String)map.get("EMPLOYEE_CODE"); response.setHeader("Content-Disposition", "attachment; filename=afterSessionWork"+ java.net.URLEncoder.encode( employeeCode + ".xls", "UTF-8")); response.setContentType("application/octet-stream; charset=utf-8"); SimpleDateFormat sfm = new SimpleDateFormat("yyyy-MM-dd"); String filename = employeeCode + "_" + sfm.format(new Date()); String encodedfileName = new String(filename.getBytes(), "UTF-8"); InputStream in = blob.getBinaryStream(); byte[] buf = new byte[1024]; int bytesIn = 0; FileOutputStream out = new FileOutputStream(serverPath+ employeeCode+".xls"); while ((bytesIn = in.read(buf, 0, 1024)) != -1) { out.write(buf, 0, bytesIn); } srcfile.add(new File(serverPath+"\\"+encodedfileName+".xls")); in.close(); out.close(); } } //将服务器上存放Excel的文件夹打成zip包 File zipfile = new File(serverPath+"PreWork"+".zip"); ZipUtils.zipFiles(srcfile, zipfile); // //下载 ZipUtils.downFile(response,serverPath, "PreWork"+".zip"); // return null; } //工具类 public class ZipUtils { /** * 将多个Excel打包成zip文件 * @param srcfile * @param zipfile */ public static void zipFiles(List<File> srcfile, File zipfile) { byte[] buf = new byte[1024]; try { // Create the ZIP file ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipfile)); // Compress the files for (int i = 0; i < srcfile.size(); i++) { File file = srcfile.get(i); FileInputStream in = new FileInputStream(file); // Add ZIP entry to output stream. out.putNextEntry(new ZipEntry(file.getName())); // Transfer bytes from the file to the ZIP file int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } // Complete the entry out.closeEntry(); in.close(); } // Complete the ZIP file out.close(); } catch (IOException e) { e.printStackTrace(); } } public static void downFile(HttpServletResponse response,String serverPath, String str) { try { String path = serverPath + str; File file = new File(path); if (file.exists()) { InputStream ins = new FileInputStream(path); BufferedInputStream bins = new BufferedInputStream(ins);// 放到缓冲流里面 OutputStream outs = response.getOutputStream();// 获取文件输出IO流 BufferedOutputStream bouts = new BufferedOutputStream(outs); response.setContentType("application/x-download");// 设置response内容的类型 response.setHeader( "Content-disposition", "attachment;filename=" + URLEncoder.encode(str, "UTF-8"));// 设置头部信息 int bytesRead = 0; byte[] buffer = new byte[8192]; //开始向网络传输文件流 while ((bytesRead = bins.read(buffer, 0, 8192)) != -1) { bouts.write(buffer, 0, bytesRead); } bouts.flush();// 这里一定要调用flush()方法 ins.close(); bins.close(); outs.close(); bouts.close(); } else { response.sendRedirect("../error.jsp"); } } catch (IOException e) { e.printStackTrace(); } } } ```

关于Java的FTP文件下载功能,求大神指教(附代码)

最近在做一个FTP文件下载的功能,包括单个文件下载和打包文件下载,但是代码写出来以后经过各种调试测试,发现无论单个文件下载还是打包文件下载,都无法使用迅雷下载,只能使用浏览器进行下载,而且在下载的过程中不会显示进度条,但是文件下载下来的文件是很正常的。 ``` //单个文件下载 public void Ftpdownload(String reaName,String fileName,String remote,HttpServletResponse response,HttpServletRequest request) throws IOException { // 开启输出流弹出文件保存路径选择窗口 response.setContentType("application/octet-stream"); response.setContentType("application/OCTET-STREAM;charset=UTF-8"); //解决下载文件中文名称乱码的问题 String agent = request.getHeader("USER-AGENT"); if(agent != null && agent.toLowerCase().indexOf("firefox") > 0) { reaName = "=?UTF-8?B?" + (new String(Base64.encodeBase64(reaName.getBytes("UTF-8")))) + "?="; } else { reaName = java.net.URLEncoder.encode(reaName, "UTF-8"); } response.setHeader("Content-Disposition", "attachment;filename=" +reaName); OutputStream out = response.getOutputStream(); // 转移到FTP服务器目录至指定的目录下 ftpClient.changeWorkingDirectory(new String(remote.getBytes(LOCAL_CHARSET), SERVER_CHARSET)); //下载FTP服务器指定文件 ftpClient.retrieveFile(new String(fileName.getBytes(LOCAL_CHARSET), SERVER_CHARSET), out); out.close(); } ``` ``` //打包下载 public void download(Map<String,String> map,String isbn,HttpServletResponse response){ // 开启输出流弹出文件保存路径选择窗口 response.setContentType("application/octet-stream"); response.setContentType("application/OCTET-STREAM;charset=UTF-8"); //解决下载文件中文名称乱码的问题 try { SimpleDateFormat simpleDateFormat; simpleDateFormat = new SimpleDateFormat("yyyyMMdd"); Date date = new Date(); String folderName=isbn+"-"+simpleDateFormat.format(date); response.setHeader("Content-Disposition", "attachment;filename=" +URLEncoder.encode(folderName+".zip", "UTF-8")); } catch (UnsupportedEncodingException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //设置缓存大小 byte[] buffer = new byte[1024]; OutputStream out; try { out = response.getOutputStream(); //开启压缩流 ZipOutputStream zipout = new ZipOutputStream(out); int len; FTPFile[] listFiles=ftpClient.listFiles(); Set<String> set = map.keySet(); List<InputStream> list = new ArrayList<InputStream>(); for (String key : set) { // 转移到FTP服务器目录至指定的目录下 ftpClient.changeWorkingDirectory(new String(map.get(key) .getBytes(LOCAL_CHARSET), SERVER_CHARSET)); String string = new String(key.getBytes(LOCAL_CHARSET),SERVER_CHARSET); //从FTP服务器下载文件到文件流 InputStream retrieveFileStream = ftpClient .retrieveFileStream(string); //标记为压缩包中内的一个新文件 zipout.putNextEntry(new ZipEntry(key)); //写入输出流 while ((len = retrieveFileStream.read(buffer)) > 0) { zipout.write(buffer, 0, len); } //关闭下载流 retrieveFileStream.close(); //FTP内置方法,必须调用才能下载下一个文件流 ftpClient.completePendingCommand(); } //关闭压缩流 zipout.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } ```

java list.get(position)返回的是一个新的对象还是地址?

假设有一个类 class A;有一个集合List<A> list;集合里面存放了很多A; 这时新建了一个A a = list.get(5);这个a和list.get(5)是同一个对象吗?

java 统计集合中对象的不特定字段的平均值

![动态统计某字段](https://img-ask.csdn.net/upload/201810/30/1540894792_28871.png) ![图片说明](https://img-ask.csdn.net/upload/201810/30/1540895183_497849.png) ``` private RecordLevelModel getRecordLevelModel(Map.Entry<Integer, List<EsFitnessTestRecordDO>> entry, List<EsFitnessTestRecordDO> projectAndSexList) { RecordLevelModel bmiMaleModel = new RecordLevelModel().setGradeNumber(entry.getKey()); Integer bmiUrbanMaleTotal = projectAndSexList.size(); Map<String,Long> bmiMaleMap = projectAndSexList.stream().collect( Collectors.groupingBy(EsFitnessTestRecordDO::getBmiRating,Collectors.counting())); for(Map.Entry<String,Long> entry1 : bmiMaleMap.entrySet()) { LevelAndRegionModel levelAndRegionModel = new LevelAndRegionModel(); double rate = entry1.getValue()/bmiUrbanMaleTotal; levelAndRegionModel.setLevelName(entry1.getKey()).setRate(rate).setTotal(Integer.parseInt(entry1.getValue().toString())); bmiMaleModel.getLevelModelList().add(levelAndRegionModel); } String projectName = ""; Class<EsFitnessTestRecordDO> clz = EsFitnessTestRecordDO.class; try { String methodName = "get"+projectName; Method method = EsFitnessTestRecordDO.class.getMethod(methodName); double ave = projectAndSexList.stream().mapToDouble(method).average().average().getAsDouble(); double average = projectAndSexList.stream().mapToDouble(EsFitnessTestRecordDO::getBmi).average().getAsDouble(); }catch (NoSuchMethodException e){ } return bmiMaleModel; } ``` 写了动态指定单个字段的分组,但是 MethodHandle handle = lookup.findGetter(this.getT().getClass(), fieldName, String.class); 会报错找不到字段,我确定字段没写错 ``` public class CollectionsUtils<T> { private T t; public T getT() { return t; } public void setT(T t) { this.t = t; } public CollectionsUtils(T t) { this.t = t; } //多字段排序 public <T> Map<List<String>, List<T>> DynamicGroupListByFiled(List<T> data, String[] groupByFieldNames) { final MethodHandles.Lookup lookup = MethodHandles.lookup(); List<MethodHandle> handles = Arrays.stream(groupByFieldNames) .map(field -> { try { return lookup.findGetter(this.getT().getClass(), field, String.class); } catch (Exception e) { throw new RuntimeException(e); } }).collect(Collectors.toList()); return data.stream().collect(Collectors.groupingBy( d -> handles.stream() .map(handle -> { try { return (String) handle.invokeExact(d); } catch (Throwable e) { throw new RuntimeException(e); } }).collect(Collectors.toList()) )); } //按某字段分组后统计数量 public Map<String, Long> DynamicGroupListByFiled(List<T> data, String fieldName) { final MethodHandles.Lookup lookup = MethodHandles.lookup(); try { MethodHandle handle = lookup.findGetter(this.getT().getClass(), fieldName, String.class); return data.stream().collect(Collectors.groupingBy( d -> { try { return (String) handle.invokeExact(d); } catch (Throwable e) { throw new RuntimeException(e); } } ,Collectors.counting())); } catch (Throwable e) { throw new RuntimeException(); } } //算不定字段平均值 public Double getDynamicFieldAverage(List<T> data, String fieldName) { final MethodHandles.Lookup lookup = MethodHandles.lookup(); try { MethodHandle handle = lookup.findGetter(this.getT().getClass(), fieldName, String.class); return data.stream().mapToDouble(d -> { try { return (Double) handle.invokeExact(d); } catch (Throwable e) { throw new RuntimeException(e); } } ).average().getAsDouble(); } catch (Exception e) { throw new RuntimeException(e); } } } @Test public void testCollectionUtils() { List<EsFitnessTestRecordDO> list = new ArrayList<>(); list.add(new EsFitnessTestRecordDO().setBmiRating("优秀").setBmiScore(90D)); list.add(new EsFitnessTestRecordDO().setBmiRating("优秀").setBmiScore(92D)); list.add(new EsFitnessTestRecordDO().setBmiRating("优秀").setBmiScore(94D)); list.add(new EsFitnessTestRecordDO().setBmiRating("良好").setBmiScore(80D)); list.add(new EsFitnessTestRecordDO().setBmiRating("良好").setBmiScore(82D)); list.add(new EsFitnessTestRecordDO().setBmiRating("良好").setBmiScore(84D)); list.add(new EsFitnessTestRecordDO().setBmiRating("合格").setBmiScore(70D)); list.add(new EsFitnessTestRecordDO().setBmiRating("合格").setBmiScore(76D)); list.add(new EsFitnessTestRecordDO().setBmiRating("不合格").setBmiScore(50D)); list.add(new EsFitnessTestRecordDO().setBmiRating("不合格").setBmiScore(40D)); list.add(new EsFitnessTestRecordDO().setBmiRating("不合格").setBmiScore(30D)); CollectionsUtils<EsFitnessTestRecordDO> ct = new CollectionsUtils(EsFitnessTestRecordDO.class); //统计bmiRating字段 优秀、良好、合格、不合格的各自人数,bmiRating是传递的参数 Map<String, Long> map = ct.DynamicGroupListByFiled(list,"bmiRating"); //计算bmiScore字段的平均值,bmiScore是传递的动态参数 double bmiAverage = ct.getDynamicFieldAverage(list,"bmiScore"); } ``` ![类的字段](https://img-ask.csdn.net/upload/201810/31/1540949963_127506.png) 调试bug图 ![BUG](https://img-ask.csdn.net/upload/201810/31/1540947738_269708.png)

如何快速高效的比较两个List<String []>对象,里面的数值完全相等。

List<String[]> list1 = new ArrayList<>(); List<String[]> list2 = new ArrayList<>(); String [] line1 = new String[] {"3","4","5","6","7"}; String [] line2 = new String[] {"3","4","5","6","7"}; String [] line3 = new String[] {"4","5","6","7","8"}; String [] line4 = new String[] {"4","5","6","7","8"}; list1.add(line1);list1.add(line3); list2.add(line2);list2.add(line4); 两个list中所存的String数组数值是一样的,做指向地址不一样,用list的retainAll(),containsAll(),removeAll()均无法解决。

C/C++学习指南全套教程

C/C++学习的全套教程,从基本语法,基本原理,到界面开发、网络开发、Linux开发、安全算法,应用尽用。由毕业于清华大学的业内人士执课,为C/C++编程爱好者的教程。

定量遥感中文版 梁顺林著 范闻捷译

这是梁顺林的定量遥感的中文版,由范闻捷等翻译的,是电子版PDF,解决了大家看英文费时费事的问题,希望大家下载看看,一定会有帮助的

YOLOv3目标检测实战:训练自己的数据集

YOLOv3是一种基于深度学习的端到端实时目标检测方法,以速度快见长。本课程将手把手地教大家使用labelImg标注和使用YOLOv3训练自己的数据集。课程分为三个小项目:足球目标检测(单目标检测)、梅西目标检测(单目标检测)、足球和梅西同时目标检测(两目标检测)。 本课程的YOLOv3使用Darknet,在Ubuntu系统上做项目演示。包括:安装Darknet、给自己的数据集打标签、整理自己的数据集、修改配置文件、训练自己的数据集、测试训练出的网络模型、性能统计(mAP计算和画出PR曲线)和先验框聚类。 Darknet是使用C语言实现的轻型开源深度学习框架,依赖少,可移植性好,值得深入探究。 除本课程《YOLOv3目标检测实战:训练自己的数据集》外,本人推出了有关YOLOv3目标检测的系列课程,请持续关注该系列的其它课程视频,包括: 《YOLOv3目标检测实战:交通标志识别》 《YOLOv3目标检测:原理与源码解析》 《YOLOv3目标检测:网络模型改进方法》 敬请关注并选择学习!

sql语句 异常 Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your

在我们开发的工程中,有时候会报 [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ------ 这种异常 不用多想,肯定是我们的sql语句出现问题,下面...

浪潮集团 往年的软件类 笔试题 比较详细的哦

浪潮集团 往年的软件类 笔试题 比较详细的哦

2019 AI开发者大会

2019 AI开发者大会(AI ProCon 2019)是由中国IT社区CSDN主办的AI技术与产业年度盛会。多年经验淬炼,如今蓄势待发:2019年9月6-7日,大会将有近百位中美顶尖AI专家、知名企业代表以及千余名AI开发者齐聚北京,进行技术解读和产业论证。我们不空谈口号,只谈技术,诚挚邀请AI业内人士一起共铸人工智能新篇章!

I2c串口通信实现加速度传感器和FPGA的交流

此代码能实现加速度传感器与FPGA之间的交流,从而测出运动物体的加速度。

Python可以这样学(第一季:Python内功修炼)

董付国系列教材《Python程序设计基础》、《Python程序设计(第2版)》、《Python可以这样学》配套视频,讲解Python 3.5.x和3.6.x语法、内置对象用法、选择与循环以及函数设计与使用、lambda表达式用法、字符串与正则表达式应用、面向对象编程、文本文件与二进制文件操作、目录操作与系统运维、异常处理结构。

微信公众平台开发入门

本套课程的设计完全是为初学者量身打造,课程内容由浅入深,课程讲解通俗易懂,代码实现简洁清晰。通过本课程的学习,学员能够入门微信公众平台开发,能够胜任企业级的订阅号、服务号、企业号的应用开发工作。 通过本课程的学习,学员能够对微信公众平台有一个清晰的、系统性的认识。例如,公众号是什么,它有什么特点,它能做什么,怎么开发公众号。 其次,通过本课程的学习,学员能够掌握微信公众平台开发的方法、技术和应用实现。例如,开发者文档怎么看,开发环境怎么搭建,基本的消息交互如何实现,常用的方法技巧有哪些,真实应用怎么开发。

机器学习初学者必会的案例精讲

通过六个实际的编码项目,带领同学入门人工智能。这些项目涉及机器学习(回归,分类,聚类),深度学习(神经网络),底层数学算法,Weka数据挖掘,利用Git开源项目实战等。

eclipseme 1.7.9

eclipse 出了新的eclipseme插件,官方有下载,但特慢,我都下了大半天(可能自己网速差)。有急需要的朋友可以下哦。。。

Spring Boot -01- 快速入门篇(图文教程)

Spring Boot -01- 快速入门篇 今天开始不断整理 Spring Boot 2.0 版本学习笔记,大家可以在博客看到我的笔记,然后大家想看视频课程也可以到【慕课网】手机 app,去找【Spring Boot 2.0 深度实践】的课程,令人开心的是,课程完全免费! 什么是 Spring Boot? Spring Boot 是由 Pivotal 团队提供的全新框架。Spring Boot...

HoloLens2开发入门教程

本课程为HoloLens2开发入门教程,讲解部署开发环境,安装VS2019,Unity版本,Windows SDK,创建Unity项目,讲解如何使用MRTK,编辑器模拟手势交互,打包VS工程并编译部署应用到HoloLens上等。

最简单的倍频verilog程序(Quartus II)

一个工程文件 几段简单的代码 一个输入一个输出(50Mhz倍频到100Mhz)

计算机组成原理实验教程

西北工业大学计算机组成原理实验课唐都仪器实验帮助,同实验指导书。分为运算器,存储器,控制器,模型计算机,输入输出系统5个章节

4小时玩转微信小程序——基础入门与微信支付实战

这是一个门针对零基础学员学习微信小程序开发的视频教学课程。课程采用腾讯官方文档作为教程的唯一技术资料来源。杜绝网络上质量良莠不齐的资料给学员学习带来的障碍。 视频课程按照开发工具的下载、安装、使用、程序结构、视图层、逻辑层、微信小程序等几个部分组织课程,详细讲解整个小程序的开发过程

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

基于RSA通信密钥分发的加密通信

基于RSA通信密钥分发的加密通信,采用pycrypto中的RSA、AES模块实现

不同变质程度煤尘爆炸残留气体特征研究

为分析不同变质程度煤尘爆炸残留气体成分的特征规律,利用水平管道煤尘爆炸实验装置进行了贫瘦煤、肥煤、气煤、长焰煤4种不同变质程度的煤尘爆炸实验,研究了不同变质程度煤尘爆炸后气体残留物含量的差异,并对气体

设计模式(JAVA语言实现)--20种设计模式附带源码

课程亮点: 课程培训详细的笔记以及实例代码,让学员开始掌握设计模式知识点 课程内容: 工厂模式、桥接模式、组合模式、装饰器模式、外观模式、享元模式、原型模型、代理模式、单例模式、适配器模式 策略模式、模板方法模式、观察者模式、迭代器模式、责任链模式、命令模式、备忘录模式、状态模式、访问者模式 课程特色: 笔记设计模式,用笔记串连所有知识点,让学员从一点一滴积累,学习过程无压力 笔记标题采用关键字标识法,帮助学员更加容易记住知识点 笔记以超链接形式让知识点关联起来,形式知识体系 采用先概念后实例再应用方式,知识点深入浅出 提供授课内容笔记作为课后复习以及工作备查工具 部分图表(电脑PC端查看):

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

软件测试2小时入门

本课程内容系统、全面、简洁、通俗易懂,通过2个多小时的介绍,让大家对软件测试有个系统的理解和认识,具备基本的软件测试理论基础。 主要内容分为5个部分: 1 软件测试概述,了解测试是什么、测试的对象、原则、流程、方法、模型;&nbsp; 2.常用的黑盒测试用例设计方法及示例演示;&nbsp; 3 常用白盒测试用例设计方法及示例演示;&nbsp; 4.自动化测试优缺点、使用范围及示例‘;&nbsp; 5.测试经验谈。

几率大的Redis面试题(含答案)

本文的面试题如下: Redis 持久化机制 缓存雪崩、缓存穿透、缓存预热、缓存更新、缓存降级等问题 热点数据和冷数据是什么 Memcache与Redis的区别都有哪些? 单线程的redis为什么这么快 redis的数据类型,以及每种数据类型的使用场景,Redis 内部结构 redis的过期策略以及内存淘汰机制【~】 Redis 为什么是单线程的,优点 如何解决redis的并发竞争key问题 Red...

手把手实现Java图书管理系统(附源码)

【超实用课程内容】 本课程演示的是一套基于Java的SSM框架实现的图书管理系统,主要针对计算机相关专业的正在做毕设的学生与需要项目实战练习的java人群。详细介绍了图书管理系统的实现,包括:环境搭建、系统业务、技术实现、项目运行、功能演示、系统扩展等,以通俗易懂的方式,手把手的带你从零开始运行本套图书管理系统,该项目附带全部源码可作为毕设使用。 【课程如何观看?】 PC端:https://edu.csdn.net/course/detail/27513 移动端:CSDN 学院APP(注意不是CSDN APP哦) 本课程为录播课,课程2年有效观看时长,大家可以抓紧时间学习后一起讨论哦~ 【学员专享增值服务】 源码开放 课件、课程案例代码完全开放给你,你可以根据所学知识,自行修改、优化

jsp+servlet入门项目实例

jsp+servlet实现班级信息管理项目

winfrom中嵌套html,跟html的交互

winfrom中嵌套html,跟html的交互,源码就在里面一看就懂,很简单

Java面试题大全(2020版)

发现网上很多Java面试题都没有答案,所以花了很长时间搜集整理出来了这套Java面试题大全,希望对大家有帮助哈~ 本套Java面试题大全,全的不能再全,哈哈~ 一、Java 基础 1. JDK 和 JRE 有什么区别? JDK:Java Development Kit 的简称,java 开发工具包,提供了 java 的开发环境和运行环境。 JRE:Java Runtime Environ...

python实现数字水印添加与提取及鲁棒性测试(GUI,基于DCT,含测试图片)

由python写的GUI,可以实现数字水印的添加与提取,提取是根据添加系数的相关性,实现了盲提取。含有两种攻击测试方法(高斯低通滤波、高斯白噪声)。基于python2.7,watermark.py为主

Xshell6完美破解版,亲测可用

Xshell6破解版,亲测可用,分享给大家。直接解压即可使用

你连存活到JDK8中著名的Bug都不知道,我怎么敢给你加薪

CopyOnWriteArrayList.java和ArrayList.java,这2个类的构造函数,注释中有一句话 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 public ArrayList(Collection&lt;? ...

相关热词 c#框体中的退出函数 c# 按钮透明背景 c# idl 混编出错 c#在位置0处没有任何行 c# 循环给数组插入数据 c# 多线程死锁的例子 c# 钉钉读取员工排班 c# label 不显示 c#裁剪影像 c#工作进程更新ui
立即提问