草庐IT

Is_Numeric

全部标签

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 - 循环增量 : Which is "better"?

当您有一个表示为数组的循环缓冲区,并且您需要环绕索引(即,当您达到可能的最高索引并递增它时),是否“更好”:return(++i==buffer.length)?0:i;或者return++i%buffer.length;使用模运算符有什么缺点吗?它比第一个解决方案的可读性差吗?编辑:当然应该是++i而不是i++,改了。编辑2:一个有趣的注意事项:我在DougLea的ArrayBlockingQueue实现中找到了第一行代码。 最佳答案 Update:OPhasadmittedinacommentthatitshouldhavebe

java - 如果 Itunes :Keep iTunes Folder Organized is set programmatically on Windows,我该如何解决

如果Itunes:Preferences:Advanced:KeepiTunesFolderOrganized在Windows上以编程方式设置,我该如何解决,我与iTunes交互的Java应用程序需要知道这一点。不幸的是,iTunesxml文件或ItunesCOMAPI似乎都没有提供此信息,我认为是因为它们是存储在其他地方的首选项但是我如何才能确定是否启用,我还需要知道这个添加到资料库时将文件复制到iTunesMedia文件夹更新:注册表中没有任何内容,但我找到了一个首选项文件C:\Users\用户名\AppData\Roaming\AppleComputer\iTunes但是它似乎是

java - 如何使用 selenium 处理 firefox 中的 "Your connection is not secure"错误

我正在使用webdriverV3.0.1和firefoxV46。我遇到了“您的连接不安全”的错误。请帮我解决这个问题。你可以在下面找到我的代码System.setProperty("webdriver.gecko.driver","D:\\Software\\Webdriver\\geckonew\\geckodriver-v0.11.1-win64\\geckodriver.exe");FirefoxProfileprofile=newFirefoxProfile();profile.setPreference("network.proxy.type",0);profile.setA

java - 强化高 : Access specifier manipulation on reflection that is used to invoke a private constructor

我使用反射来调用类的私有(private)构造函数,以解决Sonar扫描报告显示的分支覆盖不足问题。这是我正在工作的代码片段://reflectiontoaccessaprivateconstructorofaclassConstructorc=CMISBridgeMaps.class.getDeclaredConstructor(newClass[0]);c.setAccessible(true);cmisBridgeMaps=c.newInstance(newObject[0]);以上代码解决了我的Sonar扫描关键问题。但不幸的是,fortify现在在以下行中显示访问说明符操作问

java - 为什么 Weld 在 Tomcat 上显示 "Injection into Listeners is not supported"?

我有一个使用Resteasy的Web项目(它又使用Weld)并部署到Tomcat7.0.22(我把具体版本放在这里以防这个问题是这个版本特有的)。我有一个如下所示的ServletContextListener:@WebListenerpublicclassApplicationInitialisationListenerimplementsServletContextListener{//createaloggerhere@InjectHealthCheckhealthCheck;@OverridepublicvoidcontextInitialized(ServletContextE

Java 小服务程序 : Best Way to Determine if request is AJAX

确定进入javaservlet的GET或POST请求是否为AJAX请求的最佳方法是什么?到目前为止,我在搜索中遇到的方法是使用从标题中删除信息"XMLHttpRequest".equals(request.getHeader("X-Requested-With"));还有其他方法可以解决这个问题吗?似乎依赖header并不是一个非常可靠的解决方案。 最佳答案 以下HTML文档使用jQuery.post()方法向Servlet发送异步AJAX请求:clickdemobody{font-family:verdana;margin:20p