在过去的两天内,我一直在阅读有关编码Unicode Java 9紧凑型字符串的知识,我的情况还不错。但是有些我不明白。
关于字节数据类型
1)。是8位存储范围从-128到127
问题
1)。为什么Java没有像char unsigned 16 bits那样实现它?我的意思是它将在0.256的范围内,因为从0到127仅可以保存一个Ascii值,但是如果我将值设置为200,扩展的ascii将会溢出到-56会发生什么。
2)。负值是否表示我在用Java 11尝试过一个简单示例的意思?
final char value = (char)200;//in byte would overflow
final String stringValue = new String(new char[]{value});
System.out.println(stringValue);//THE SAME VALUE OF JAVA 8
Run Code Online (Sandbox Code Playgroud)
我检查了String.value变量,然后看到一个字节数组
System.out.println(value[0]);//-56
Run Code Online (Sandbox Code Playgroud)
像以前一样出现相同的问题,-56是否表示我检测到该溢出的其他语言中的(负值),则返回值200?Java如何知道-56的值与char中的200相同。
我尝试了最困难的示例,如代码点128048,并且在String.value变量中看到了这样的字节数组。
0 = 61
1 = -40
2 = 48
3 = -36
Run Code Online (Sandbox Code Playgroud)
我知道此代码点需要4个字节,但我知道如何将char []转换为byte [],但我不知道String如何处理此byte []数据。
很抱歉,这个问题很简单,很抱歉,任何键入英语都不是我的自然语言,非常感谢。
我有一个像这样的简单代码
import java.util.function.Supplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;
public class StreamSupplierVersusConcat {
public static void main(String[] args) {
final StreamSupplierVersusConcat clazz = new StreamSupplierVersusConcat();
clazz.doConcat();
}
private void doConcat(){
System.out.println(Stream.concat(buildStreamFromRange(0,1000).get()
,buildStreamFromRange(1000,2000).get())
.anyMatch("1"::equals));
}
private Supplier<Stream<String>>buildStreamFromRange(final int start,final int end){
return ()->IntStream.range(start, end)
.mapToObj(i->{
System.out.println("index At: "+i);
return String.valueOf(i);
});
}
}
Run Code Online (Sandbox Code Playgroud)
我知道 concat 是懒惰的,所以当我运行代码时,我看到它只生成了 2 个很棒的值,但知道 distinct 是一个有状态的操作,我认为将该方法放在 Stream 管道上它会生成所有值,然后做 anyMatch 方法,但如果我这样说
private void doConcat(){
System.out.println(Stream.concat(buildStreamFromRange(0,1000).get()
,buildStreamFromRange(1000,2000).get())
.distinct()//ARE ALL THE VALUES GENERATED NOT REQUIRED HERE???
.anyMatch("1"::equals));
}
Run Code Online (Sandbox Code Playgroud)
但是有了不同的和没有它,我得到了相同的回应。
index At: 0 …Run Code Online (Sandbox Code Playgroud) 我有一个主要细节与2个子vertically报告背靠背他们没有太多的空间,因为主报告很长....我已经在两个子报告中指定FLOAT属性一切顺利,当两个填充空间的数据分配它在IREPORT但是当他们有很多行我的意思的3 or more rows第二子报表Materiales重叠在下一组件......如果有些报表需要更多的空间,这将推动下一个组件下来,我想.的TRABAJOS REALIZADOS是成Frame with Float property,但没有被按下该帧被保持的位置和得到由重叠Materiales sub-report..
我的ireport设计.

my source code some tags are ommited by brevity
<detail>
<band height="770" splitType="Stretch">
.... others tags ommited by brevity
<frame>
<reportElement positionType="Float" x="0" y="401" width="554" height="70"/>
<subreport runToBottom="false">
<reportElement positionType="Float" x="1" y="1" width="553" height="69"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{munichs})]]></dataSourceExpression>
<subreportExpression class="java.io.InputStream"><![CDATA[$P{SUBREPORT_EXPRESSION}]]></subreportExpression>
</subreport>
</frame>
<frame>
<reportElement positionType="Float" x="2" y="472" width="551" height="128"/>
<subreport runToBottom="false">
<reportElement positionType="Float" x="1" y="44" width="545" height="83"/> …Run Code Online (Sandbox Code Playgroud) 我有这样的课
public class Student
{
private String reference;
private String aPlaceAt;
//methods generate by Netbeans Eclipse generates the same methods
public String getaPlaceAt(){return aPlaceAt;}
public void setaPlaceAt(String aPlaceAt){this.aPlaceAt = aPlaceAt;}
public String getReference(){return reference;}
public void setReference(String reference){this.reference = reference;}
}
Run Code Online (Sandbox Code Playgroud)
后来我需要找到每个属性的setter和getter,reflection我使用下面的代码
public Method findSetterFor(final Class clazz,final String propertyName) throws Exception
{
return new PropertyDescriptor(propertyName,clazz).getWriteMethod();
}
for(final Field field:clazz.testClazz.getDeclaredFields())
System.out.println(field.getName()+" "+clazz.findSetterFor(clazz.testClazz,field.getName()));
Run Code Online (Sandbox Code Playgroud)
他们返回正确的setter以供参考,但是对于属性aPlaceAt
投
Exception in thread "main" java.beans.IntrospectionException: Method not found: isAPlaceAt
Run Code Online (Sandbox Code Playgroud)
为什么是啊?不应该
public void setaPlaceAt(String aPlaceAt){this.aPlaceAt …Run Code Online (Sandbox Code Playgroud) 我正在打字,我想知道如何在静态上下文中调用默认方法,我有一个这样的代码段。
interface InterfaceWithDefaultMethod{
public default void saySomething(final int a,final int b){System.out.println(String.format("Parameters are %d %d",a,b));}
}
public class StaticsMethodIsNotOverriden2 implements InterfaceWithDefaultMethod {
public static void main(String[] args) {
final StaticsMethodIsNotOverriden2 clazz = new StaticsMethodIsNotOverriden2();
clazz.saySomething(13,20);//Overriden method call with 13 20
clazz.callDefaultSaySomethingFromInstance();//Parameters are 1 2
/*HOW CALL public default void saySomething(final int a,final int b) METHOD HERE....????*/
clazz.InterfaceWithDefaultMethod.super.saySomething(1, 2);/*no enclosing instance of type InterfaceWithDefaultMethod is in scope*/
}
@Override
public void saySomething(int a, int b) {
System.out.println(String.format("Overriden method call with %d %d",a,b)); …Run Code Online (Sandbox Code Playgroud) 我有这样的查询.我传递学生证我需要学生以及他们的父母的一些字段以及父母的一些字段 - >地址[这是我面临的主要问题]我正在使用Sami Andoni的AliasToBeanNestedResultTransformer变压器
这里是CODE的实现
这是我的代码.
public List<Student>searchForStudent(Integer studentId)
{
Projection p=Projections.projectionList().create()
.add(Projections.property("name"),"name")//the student name it works O.K
.add(Projections.property("lastname"),"lastname")//the student name it works O.K
.add(Projections.property("age"),"age")//the student AGE it works O.K
.add(Projections.property("p.phone"),"parent.phone")//the parent phone it works O.K
.add(Projections.property("address.state").as("parent.Address.state")); // i need a field from address.state here is the problem...
Session session = ......
Criteria like = session.createCriteria(Student.class).add(prepareForSelect())//some filters..
.createAlias("parent","p")//the parent of the student. a student have one parent
.createAlias("parent.Address","address")//the address of the parent.... a parent have …Run Code Online (Sandbox Code Playgroud) 我正在阅读Java 8中的新的java.time API
像这样的东西
public final class DaysWithBaby
{
private final LocalDate sheSayYes = LocalDate.of(2008,Month.APRIL,26);
private final LocalDate today = LocalDate.now().plusDays(1);
public static void main(String[] args)
{
final DaysWithBaby clazz = new DaysWithBaby();
System.out.println(Period.between(clazz.sheSayYes,clazz.today).getDays());
System.out.println(ChronoUnit.DAYS.between(clazz.sheSayYes,clazz.today));
}
}
Run Code Online (Sandbox Code Playgroud)
两个输出都列在下面.
1
2467
Run Code Online (Sandbox Code Playgroud)
我认为这个结果是正确的
System.out.println(ChronoUnit.DAYS.between(clazz.sheSayYes,clazz.today));
Run Code Online (Sandbox Code Playgroud)
但是这个结果又回来了 1
System.out.println(Period.between(clazz.sheSayYes,clazz.today).getDays());
Run Code Online (Sandbox Code Playgroud)
我做错了什么任何帮助都非常感激.
我是 Maven 新手。我需要包括
private javafx.embed.swing.JFXPanel jFXPanel1;
Run Code Online (Sandbox Code Playgroud)
使用 Maven + Jigsaw 模块的新项目。
我的包有以下问题javafx.embed.swing。
我以为添加这个依赖项会起作用,但事实并非如此。
private javafx.embed.swing.JFXPanel jFXPanel1;
Run Code Online (Sandbox Code Playgroud)
在全新安装时,我看到以下内容
(包 javafx.embed.swing 在未命名模块中声明,但模块 com.my.module 不读取它)
我不明白这一点。我看到那个JAR,它只有一个清单文件,没有任何.class文件,这让我更加困惑。
如果我查看 m2 文件夹,我会看到一个不同的 JAR,具有相同的前缀,但带有win后缀,并且在那里我看到了该包。
我认为这就是分类器
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-swing -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>19</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我想,但我不知道,这个 jar 是否被 Maven 选择,但似乎没有,因为我在 IntelliK 库中没有看到它。
我对 JavaFX 没有任何问题,一切都是模块化的并且正在运行。我只有这个罐子有问题。
- - - - - - - - - - - - - - -更新 - - - - - - - - - - ----------------
这里的罪魁祸首是 IntellijIdea,我确实单击了 …