草庐IT

is_iterator

全部标签

java - 使用 Jersey : FormDataContentDisposition is null 上传文件

我正在尝试使用Jersey实现文件上传,所以我遵循了这个例子:http://www.mkyong.com/webservices/jax-rs/file-upload-example-in-jersey/它适用于HTML页面。现在我将它调整到我的应用程序中,这里是代码:publicResponseuploadFile(@FormDataParam("file")InputStreamuploadedInputStream,@FormDataParam("file")FormDataContentDispositionfileDetail)throwsIOException{Respon

Java secondary not public 类的使用会产生错误 "Type is not Visible",即使访问的方法在主类中是公共(public)的

我有一个Main.java文件:publicclassMain{privateEntityDrawerentityDrawer;publicvoidsetEntityDrawer(EntityDrawerentityDrawer){this.entityDrawer=entityDrawer;}publicEntityDrawergetEntityDrawer(){returnentityDrawer;}}classEntityDrawer{privateEmpleadoempleado;publicEmpleadogetEmpleado(){returnempleado;}publi

java - "the hash table is open"在Java中是什么意思?

我在阅读有关Hashtable类的Javaapi文档时遇到了几个问题。在文档中,它说“Notethatthehashtableisopen:inthecaseofa"hashcollision",asinglebucketstoresmultipleentries,whichmustbesearchedsequentially.”我自己尝试了以下代码Hashtableme=newHashtable();me.put("one",newInteger(1));me.put("two",newInteger(2));me.put("two",newInteger(3));System.ou

java - NetBeans : diamond operator is not supported in -source 1. 5(使用 -source 7 或更高版本启用菱形运算符)

我写代码的时候不知道为什么:Listdata=newArrayList();是这样说的diamondoperatorisnotsupportedin-source1.5(use-source7orhighertoenablediamondoperator)----(Alt-Entershowshints)我已经在使用JDK1.7。当我在eclipse中打开它时,我没有得到那个错误。 最佳答案 -source1.5表示您的代码将与Java1.5版兼容,并且不能使用稍后引入的语言结构。阅读http://docs.oracle.com/j

Java Iterator实现编译错误: does not override abstract method remove()

为什么会出现以下编译错误:LRIterator不是抽象的,不会覆盖java.util.Iterator中的抽象方法remove()注意,实现是针对链表的publicIteratoriterator(){returnnewLRIterator();}privateclassLRIteratorimplementsIterator{privateDLLNodeplace;privateLRIterator(){place=first;}publicbooleanhasNext(){return(place!=null);}publicObjectnext(){if(place==null)

Java 错误 : The constructor is undefined

在Java中,为什么会出现此错误:Error:TheconstructorWeightIn()isundefinedJava代码:publicclassWeightIn{privatedoubleweight;privatedoubleheight;publicWeightIn(doubleweightIn,doubleheightIn){weight=weightIn;height=heightIn;}publicvoidsetWeight(doubleweightIn){weight=weightIn;}publicvoidsetHeight(doubleheightIn){hei

java - "LinkedList is not generic"错误Java

我在尝试创建链表时遇到错误:Exceptioninthread"main"java.lang.Error:Unresolvedcompilationproblem:ThetypeLinkedListisnotgeneric;itcannotbeparameterizedwithargumentsatLinkedList.main(LinkedList.java:7)有人知道如何解决这个错误吗?这是程序:importjava.util.*;publicclassLinkedList{publicstaticvoidmain(String[]args){Listlist=newLinked

java - 遍历列表,修改每个元素 : is there a faster method?

我有一个List的String,我想trim()列表的每个元素。目前,我正在使用ArrayList,对元素进行简单的循环,并将修剪后的元素添加到返回列表中,如下所示:intlistLen=listToTrim.size();ListtrimmedList=newArrayList(listLen);for(inti=0;i对于大型列表,是否有更有效的方法? 最佳答案 不,你很好。这与它的效率差不多。没有什么魔法可以避免迭代。有一点要记住,'不过:如果listToTrim不是随机访问列表(即它不实现RandomAccess),那么使用

java - Play Framework : PersistenceException: The type is not a registered entity? (Ebean)

我正在学习适用于Java的PlayFramework2.0教程,但在尝试保存ebean模型(task.save())时遇到此错误。[PersistenceException:Thetype[classmodels.Task]isnotaregisteredentity?Ifyoudon'texplicitlylisttheentityclassestouseEbeanwillsearchforthemintheclasspath.IftheentityisinaJarchecktheebean.search.jarspropertyinebean.propertiesfileorche

java - 如何在 java 中从 Iterable 创建集合?

例如,我有一组几何图形:Setfigures;有两种图形:正方形和圆形。我想使用googlecollections获取一组正方形:Iterables.filter(figures,squarePredicate);但是过滤器方法返回Iterable...我如何从Iterable创建Set?(不在Iterable上使用循环) 最佳答案 我认为您需要重新考虑您的要求。你需要一组正方形。为什么?集合只为您提供唯一性和迭代性。您在Iterable中具有唯一性,因为源是一个集合,并且您可以迭代Iterable中的项目。那你为什么需要这套?只有