草庐IT

unchecked-conversion

全部标签

使用 vector 的 Java 警告 : unchecked call to add(E)

有问题的代码Vectormoves=newVector();moves.add(newInteger(x));错误:ConnectFour.java:82:warning:[unchecked]uncheckedcalltoadd(E)asamemberoftherawtypejava.util.Vectormoves.add(newInteger(x));不太确定这样的错误需要多少信息...... 最佳答案 问题是上面的代码没有使用generics.以下将起作用:Vectormoves=newVector();move.add(n

java - 不一致的 "possible lossy conversion from int to byte"编译时错误

检查以下代码片段:片段#1inta=20;intb=30;bytec=(a>b)?20:30;Error:incompatibletypes:possiblelossyconversionfrominttobytebytec=(a>b)?20:30;片段#2inta=20;intb=30;byteh1=70;bytec=(a>b)?20:h1;片段#3inta=20;intb=30;byteh1=70;byteh2=89;bytec=(a>b)?h1:h2;片段#4bytec=(true)?20:30;除了Snippet#1之外,所有这些都可以正常编译。这种行为如何合理?如果Snipp

java - 不一致的 "possible lossy conversion from int to byte"编译时错误

检查以下代码片段:片段#1inta=20;intb=30;bytec=(a>b)?20:30;Error:incompatibletypes:possiblelossyconversionfrominttobytebytec=(a>b)?20:30;片段#2inta=20;intb=30;byteh1=70;bytec=(a>b)?20:h1;片段#3inta=20;intb=30;byteh1=70;byteh2=89;bytec=(a>b)?h1:h2;片段#4bytec=(true)?20:30;除了Snippet#1之外,所有这些都可以正常编译。这种行为如何合理?如果Snipp

java - 如何使用 -Xlint :unchecked in a Maven project? 进行编译

在NetBeans7.2中,我无法找到如何在Maven项目中使用-Xlint:unchecked进行编译。在Ant项目下,您可以通过转到ProjectProperties->Compiling来更改编译器标志,但Maven项目似乎没有任何此类选项。有什么方法可以配置IDE以使用Maven使用此类标志进行编译? 最佳答案 我猜你可以在你的pom.xml中设置编译器参数。请引用http://maven.apache.org/plugins/maven-compiler-plugin/examples/pass-compiler-argu

java - 如何使用 -Xlint :unchecked in a Maven project? 进行编译

在NetBeans7.2中,我无法找到如何在Maven项目中使用-Xlint:unchecked进行编译。在Ant项目下,您可以通过转到ProjectProperties->Compiling来更改编译器标志,但Maven项目似乎没有任何此类选项。有什么方法可以配置IDE以使用Maven使用此类标志进行编译? 最佳答案 我猜你可以在你的pom.xml中设置编译器参数。请引用http://maven.apache.org/plugins/maven-compiler-plugin/examples/pass-compiler-argu

type-conversion - Kotlin 的 Double.toInt() 中使用了哪种方法,舍入还是截断?

开启theofficialAPIdoc,它说:ReturnsthevalueofthisnumberasanInt,whichmayinvolveroundingortruncation.我想要截断,但不确定。谁能解释一下可能涉及舍入或截断的确切含义?p.s.:在我的单元测试中,(1.7).toInt()为1,可能涉及截断。 最佳答案 Double.toInt()的KDoc简单地继承自Number.toInt(),为此,确切的含义是,它在具体的Number实现中定义如何将其转换为Int。在Kotlin中,Double操作遵循IEEE

sql-server - XPath fn :data in sql server causes Type conversion in expression may affect "CardinalityEstimate" in query plan choice

我有一个xml变量,其中包含一组我想在表中查找的ID。查询时我尝试了几个版本,但以下版本(根据我的测试)似乎是最快的:declare@idsxmlasxml(IdSchemaColelction)='505766458073460689464050'SELECT*FROMentityWHERE@idsXml.exist('/root/Id[data(.)=sql:column("id")]')=1问题是查询计划有以下警告“表达式中的类型转换(CONVERT_IMPLICIT(sql_variant,CONVERT_IMPLICIT(numeric(38,10),[xmlTest].[d

c++ - "Expected constructor, destructor, or type conversion before ' < ' token"

我遇到语法/解析错误,但我似乎找不到它。DataReader.h:11:error:expectedconstructor,destructor,ortypeconversionbefore'这里是DataReader.h:#include#include#include#ifndefDATA_H#defineDATA_H#include"Data.h"#endifvectorDataReader();//Thisisline11,wheretheerroris..这是.cpp文件:#include"DataReader.h"usingnamespacestd;vectorDataRe

C++ 编译 "error: expected constructor, destructor, or type conversion before ' =' token "

位于同一文件“foo.h”中的非常简单的代码:classXface{public:uint32_tm_tick;Xface(uint32_ttk){m_tick=tk;}}std::mapm;Xface*tmp;tmp=newXface(100);**//Error**m[1]=tmp;**//Error**tmp=newXface(200);**//Error**m[2]=tmp;**//Error**错误是错误:在“=”标记之前需要构造函数、析构函数或类型转换对于每个任务。 最佳答案 C++不是脚本语言。您可以在可执行代码块的范

c++ - 二进制 '==' : no operator found which takes a left-hand operand of type 'std::string' (or there is no acceptable conversion)

我正在编写一个比较std::strings的模板类函数。std::string是模板参数。我的问题是我无法用“==”运算符比较两个const字符串,然后我想我创建了两个非常量临时字符串变量来执行比较,但它仍然无法编译。不知道为什么。类VGraph被实例化为VGraphmyGraph;templatesize_tVGraph::find(constV&vert){Vtemp=vert;//(1)for(size_ti=0;i相关函数原型(prototype)templateconstV&VVertex::getVertex(); 最佳答案