草庐IT

my_boolean

全部标签

boolean 变量名称的 Java 命名约定 : writerEnabled vs writerIsEnabled

以下哪些声明符合Java的命名约定?privatebooleanwriterIsEnabled;//withmethodslikepublicbooleangetWriterIsEnabled()publicvoidsetWriterIsEnabled()或privatebooleanwriterEnabled;//withmethodslikepublicbooleangetWriterEnabled()publicvoidsetWriterEnabled()我个人认为名字“writerIsEnabled”更具可读性,尤其是当您在这样的if语句中使用它时-if(writerIsEna

java - 为原始 boolean 类型实现比较器?

我需要一些类implementsComparator,其中一个我想比较原始boolean(不是Boolean)值。如果它是一个Boolean,我会returnboolA.compareTo(boolB);这会返回0、-1或1。但是我该怎么做这与原语? 最佳答案 您可以查看它是如何为java.lang.Boolean实现的,因为该类自然也使用原始boolean值:publicintcompareTo(Booleanb){return(b.value==value?0:(value?1:-1));}从Java7开始,您可以简单地使用内置

Java 8+ 流 : Check if list is in the correct order for two fields of my object-instances

标题可能有点含糊,但这是我所拥有的(私有(private)化代码):具有一些字段的类,包括BigDecimal和Date:classMyObj{privatejava.math.BigDecimalpercentage;privatejava.util.Datedate;//Somemoreirrelevantfields//GettersandSetters}在另一个类中,我有这些对象的列表(即java.util.ListmyList)。我现在想要的是一个Java8流,用于检查列表的日期和百分比顺序是否适合我的validator。例如,下面的列表是真实的:[MyObj{percent

Creating my first web page using Angular

Ⅰ.Basicknowledgeaboutangular        Angularisapopularopen-sourceframeworkforbuildingwebapplications.HerearesomebasicconceptsandknowledgeaboutAngular:1.TypeScript:AngularisbuiltwithTypeScript,asupersetofJavaScriptthataddsstatictypingandotherfeaturestoenhancedevelopment.2.Components:Angularapplication

java - JAXB 编译器绑定(bind) xs :boolean to Java Boolean wrapper class, 而不是 boolean 原始类型

我正在将一个项目从JAXB1.0迁移到JAXB2.1,但我遇到了数据类型映射问题。我正在使用Antxjc绑定(bind)编译器,并且我已经成功配置了全局绑定(bind),这样(例如)xs:date映射到java.util.日历。但是,我生成的方法返回Boolean,而我想要的是boolean。这是复杂类型:生成的类如下所示:publicclassUsageAuthRateCharge{........publicBooleanisPricepointCustomFieldsRequired(){returnpricepointCustomFieldsRequired;}问题是尽管装箱会

java - 如何在java中返回一个 boolean 方法?

我需要有关如何在java中返回boolean方法的帮助。这是示例代码:publicbooleanverifyPwd(){if(!(pword.equals(pwdRetypePwd.getText()))){txtaError.setEditable(true);txtaError.setText("*Passworddidn'tmatch!");txtaError.setForeground(Color.red);txtaError.setEditable(false);}else{addNewUser();}return//what?}我希望verifyPwd()在我想调用该方法时

python - 索引错误 : boolean index did not match indexed array along dimension 0

在我将Numpy更新到1.13.1之前,我的代码工作正常。现在我得到以下错误IndexError:booleanindexdidnotmatchindexedarrayalongdimension0;dimensionis5butcorrespondingbooleandimensionis4...在这一行抛出:m=arr[np.diff(np.cumsum(arr)>=sum(arr)*i)]我似乎无法理解它。有什么建议吗?这是我的示例代码:a=[1,2,3,4,5]l=[0.85,0.90]s=sorted(a,reverse=False)arr=np.array(s)foriin

python - 可见弃用警告 : boolean index did not match indexed array along dimension 1; dimension is 2 but corresponding boolean dimension is 1

Macports更新后,我认为更新了numpy,我收到警告:VisibleDeprecationWarning:booleanindexdidnotmatchindexedarrayalongdimension1;dimensionis2butcorrespondingbooleandimensionis1inliers=n.size(pixels[distances以前没有提出过。相关代码为:#Computedistanceofallnon-zeropointsfromthecircumferencedistances=guess_feature.points_distance(pi

python - Python 的 boolean 值是按值传递的吗?

我发送了一个对bool对象的引用,并在一个方法中修改了它。方法执行完毕后,方法外的bool值不变。这让我相信Python的boolean值是按值传递的。真的吗?还有哪些其他Python类型具有这种行为? 最佳答案 Python变量不是C++意义上的“引用”。相反,它们只是绑定(bind)到内存中任意位置的对象的本地名称。如果该对象本身是可变的,则对它的更改将在已将名称绑定(bind)到该对象的其他范围内可见。许多原始类型(包括bool、int、str和tuple)是不可变的然而。您不能就地更改它们的值;相反,您将新值分配给本地范围内

python - 如何在 python 中设置和检查 boolean 标志

我正在尝试用boolean值做这样的事情:/*...otherstuff*/loggedDocument=falseforlineininFile:if(line.find(/*something*/)!=-1):println("FOUNDDOCUMENT:%s"%line)loggedDocument=trueif(loggedDocument==false):/*dosomethingelse*/但我不断收到无效的语法错误。我用谷歌搜索但找不到简单的boolean值示例,有什么想法吗? 最佳答案 您正在寻找True和False