草庐IT

non-String

全部标签

java.lang.NumberFormatException : empty String 异常

下面的代码不断给出一个java.lang.NumberFormatException:emptyString:privatevoidjButton4ActionPerformed(java.awt.event.ActionEventevt){doubleAText=Double.parseDouble(angleAField.getText());doubleBText=Double.parseDouble(angleBField.getText());doubleCText=Double.parseDouble(angleCField.getText());doubleaText=D

java - JPA 标准 : Convert int to String then select from substring of resulting String

我有一个String作为参数(实际上是一个valueOf(anInteger),并且想将它与数据库中int值的子字符串进行比较。这是我的代码:ClinicPatientsclp=null;//GetthecriteriabuilderinstancefromentitymanagerfinalCriteriaBuildercb=getEntityManager().getCriteriaBuilder();//CreatecriteriaqueryandpassthevalueobjectwhichneedstobepopulatedasresultCriteriaQuerycrite

java - JAXB/XJC 生成 JAXBElement<String> 而不仅仅是 String(以处理 null 大小写)

使用JDK1.7附带的JAXB/xjc(bin\xjc.exe)这是我的XSD的片段:生成的类显示:@XmlElementRef(name="Surname",type=JAXBElement.class,required=false)protectedJAXBElementsurname;publicJAXBElementgetSurname(){returnsurname;}publicvoidsetSurname(JAXBElementvalue){this.surname=value;}我知道JAXB使用JAXBElement来允许null,但这没有任何意义,因为任何声明为St

java - null是引用类型,是String引用还是Object引用?

这个问题在这里已经有了答案:Multipleoverloadedmethods:DoesnullequalNullPointerException?[duplicate](2个答案)关闭7年前。null是一个引用,它只是null类型,即null不是对象类型。但是,当我运行以下代码片段时,当我将null传递给方法method(null);它调用method(Strings)而不是method(对象o).如果null本身是Java定义的类型而不是对象类型,那为什么调用method(Strings)而不是method(Objecto)?publicclassTest{publicstatic

java - 解释警告 : non-varargs call of varargs method with inexact argument type for last parameter

这个问题在这里已经有了答案:WhydoIgetacompilationwarninghere(varargsmethodcallinJava)(5个答案)关闭6年前。这是我收到警告的示例代码。StringlsSQL=foMetaQuery.getSQL();StringlsNewSQL=replace(lsSQL,"''{","''{");lsNewSQL=replace(lsNewSQL,"}''","}''");lsNewSQL=replace(lsNewSQL,"}","}");lsNewSQL=MessageFormat.format(lsNewSQL,foSubstituti

java - 为什么在 Java 中初始化为 String.toString() 的 'final String' 不被视为常量

这个问题在这里已经有了答案:Javaswitchstatement:Constantexpressionrequired,butitISconstant(14个答案)CompileTimeConstantUsageinSwitchCaseJava(6个答案)关闭6年前。我用Java编写了以下代码,运行良好:publicclasstest{publicstaticvoidmain(String[]args){finalStrings1="s1";finalStrings2="s2";Strings="s1";switch(s){cases1:System.out.println("s1"

java - Netbeans 警告 : Exporting non-public type through public API

关闭。这个问题需要更多focused.它目前不接受答案。想改进这个问题吗?更新问题,使其只关注一个问题editingthispost.关闭9年前。Improvethisquestion我正在创建一个Slick2D游戏。现在,我正在创建一个Video类,其中包含内部类(FrameSize、FPS、FullScreen..)。所以我有一个OOD想法以一种方式进行包装,就像我们调用System.out.println()一样。这意味着我将拥有他的内部类的公共(public)视频类和公共(public)静态实例,但是netbeansIDE向我提示“通过公共(public)API导出非公共(pu

java - ArrayList<Integer> 自动将其类型更改为 ArrayList <String>

publicvoidrun(){setFont("Courier-24");//DefinelistasArrayListArrayListlist=newArrayList();readList(list);}privatevoidreadList(ArrayListlist){list.add("Hello");list.add(2);println("list="+list);println("Typeoflist="+list.get(0).getClass());println("Typeoflist="+list.get(1).getClass());}结果:list=[H

java - 为什么此 String 不符合垃圾回收条件?

以下代码创建一个数组和一个字符串对象。代码执行后存在多少对这些对象的引用?这两个对象是否符合垃圾回收条件?...String[]students=newString[10];StringstudentName="PeterParker";students[0]=studentName;studentName=null;...我的回答是studentName有资格进行垃圾收集。但给出的答案是两者都不符合条件。我认为students[0]指的是字符串“PeterParker”,而studentName也一样。现在studentName指的是为null,students[0]仍然指的是“Pe

java - 从 List<Foo> 到 Map<String, List<Foo>> : looking for a better implementation

让我给你看我的代码:Foo类publicclassFoo{Stringcode;Stringvalue;publicFoo(Stringcode,Stringvalue){super();this.code=code;this.value=value;}//getters/setters}主要方法(关注getFooMultiMapCode()方法):publicclassFooMain{publicstaticvoidmain(String[]args){Foofoo1=newFoo("100","foo1");Foofoo2=newFoo("200","foo2");Foofoo3=