草庐IT

integer-programming

全部标签

javascript - GraphQL 大整数错误 : Int cannot represent non 32-bit signed integer value

我正在尝试使用GraphQL在MongoDB中存储UNIX时间戳,但它发现GraphQL在处理整数方面存在限制。请参阅下面的突变:constaddUser={type:UserType,description:'Addanuser',args:{data:{name:'data',type:newGraphQLNonNull(CompanyInputType)}},resolve(root,params){params.data.creationTimestamp=Date.now();constmodel=newUserModel(params.data);constsaved=mo

java - 机器学习挑战 : diagnosing program in java/groovy (datamining, 机器学习)

我正计划用Java开发程序来提供诊断。数据集分为两部分,一是训练,二是测试。我的程序应该学会从训练数据中分类(顺便说一句,其中包含新列中每个问题的30个问题的答案,新行中的每条记录最后一列将是诊断0或1,在数据诊断列的测试部分将是空的-数据集包含大约1000条记录),然后在测试部分数据中进行预测:/我从未做过类似的事情,因此我将不胜感激有关解决类似问题的任何建议或信息。我在想JavaMachineLearning图书馆或JavaDataMiningPackage但我不确定这是否是正确的方向......?而且我仍然不确定如何应对这一挑战...请指教。一切顺利!

java - 泛型 List<String> 和 List<Integer> 未按预期运行

为什么println在转换为List后打印“tom”并且不显示任何运行时异常,而在转换为List后无法打印值1?importjava.util.Arrays;importjava.util.List;publicclassMain{publicstaticvoidmain(Stringargs[]){Listlist=Arrays.asList(1,"tom");System.out.println(((List)list).get(1));//"tom"System.out.println(((List)list).get(0));//ClassCastException:Integ

java - 为什么 Java 8 引入了 *Integer.sum(int a, int b)*

这个问题在这里已经有了答案:PurposeofObjects.isNull(...)/Objects.nonNull(...)(1个回答)关闭7年前。我刚刚注意到JDK8为Integer类引入了这个方法:/***Addstwointegerstogetherasperthe+operator.**@paramathefirstoperand*@parambthesecondoperand*@returnthesumof{@codea}and{@codeb}*@seejava.util.function.BinaryOperator*@since1.8*/publicstaticints

java - 为什么 == 对于某些 Integer 对象为真?

这个问题在这里已经有了答案:关闭10年前.PossibleDuplicate:Integerwrapperobjectssharethesameinstancesonlywithinthevalue127?我从KhalidMughalSCJP复制了以下程序片段,但我无法理解输出。publicclassRQ200_60{publicstaticvoidmain(String[]args){Integeri=-10;Integerj=-10;System.out.print(i==j);//output:true--whytrue?System.out.print(i.equals(j))

java - 未初始化的 int 与 Integer

我刚刚学习Java以准备考试,但遇到了未初始化int/Integer值的问题。classA{intx;Integery;staticintz;staticIntegerz2;publicA(){}}假设我初始化了一个A类的对象。Aa=newA();我已经在编译器中尝试过这个并得到了结果a.x==0;truea.x==null;StaticError:Badtypeincomparisonexpressiona.y==0;java.lang.NullPointerExceptiona.y==null;truea.z==0;truea.z==null;StaticError:Badtype

java - 如何在 Java 中从数组 (int[]) 创建 ArrayList (ArrayList<Integer>)

我看到了这个问题:CreateArrayListfromarray但是,当我使用以下代码尝试该解决方案时,它并不适用于所有情况:importjava.util.ArrayList;importjava.util.Arrays;importjava.util.Collection;importjava.util.List;publicclassToArrayList{publicstaticvoidmain(String[]args){//thisworksString[]elements=newString[]{"Ryan","Julie","Bob"};Listlist=newArr

java.lang.ClassCastException : java. lang.Long 无法在 java 1.6 中转换为 java.lang.Integer

即使我将Object转换为int,但也会发生此异常...实际上我的Hibernate-JPA方法是返回Object然后我将该Object转换为int...这是我的hibernate代码:@TransactionalpublicObjectgetAttendanceList(Useruser){Queryquery=entityManager.createQuery("selectCount(ad)fromAttendanceDemoadinnerjoinad.attendeeatwhereat.user=:user",Long.class);query.setParameter("us

java - 为什么需要从 Integer 转换为 int

已结束。这个问题是notreproducibleorwascausedbytypos.它目前不接受答案。此问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是on-topic在这里,这个问题的解决方式不太可能帮助future的读者。关闭6年前。Improvethisquestion我在使用TreeMap时遇到了问题。Mapa=newTreeMap();a.put(5,1);a.put(3,2);a.put(4,3);inttarget=7;System.out.println(target-a.get(5));//line6for(Map.Entryb:a.entrySet(

java - 是否保证 new Integer(i) == i 在 Java 中?

考虑以下代码段:inti=99999999;byteb=99;shorts=9999;Integerii=Integer.valueOf(9);//shouldbewithincacheSystem.out.println(newInteger(i)==i);//"true"System.out.println(newInteger(b)==b);//"true"System.out.println(newInteger(s)==s);//"true"System.out.println(newInteger(ii)==ii);//"false"很明显为什么最后一行会总是输出"fals