我从Oracle Java Archive下载了 Java 1.1 。
我尝试将其安装在 Windows 10(64 位)上......出于研究目的。
但是,它失败并出现以下错误。
不支持的 16 位应用程序
由于与 64 位版本的 Windows 不兼容,程序或功能“\??\C:\USERS\TEST\APPDATA\LOCAL\TEMP\~EXB0000\setup.exe”无法启动或运行。请联系软件供应商询问是否有 64 位 Windows 兼容版本。
但是,Java 1.1 是一个 32 位应用程序。
我该如何安装它?
我如何告诉Java我不需要初始化a以获得有效的程序并且不给我错误?
int a;
boolean b = true;
while (true) {
if (b == false) {
System.out.print(a);
break;
} else {
b = false;
a = 5;
}
}
Run Code Online (Sandbox Code Playgroud)
如果我不能,那么为什么这就是编译器的设计方式?
是否容易设计这样的编译器,或者这是一种确保我重构代码的机制?
这是不一样的问题,这一个
假设我们有三个这样的方法。它们都做同样的事情,但它们在内存分配和效率方面有何不同?方法一会在每次调用期间创建 Function 的实例,但第二个方法会这样做吗?应该始终使用第三个版本还是其中一个版本是安全的并且 JIT 编译器会负责内存优化?
class Test {
Map<String, Set<String>> mapOfSets = new HashMap<>();
static final Function<String, Set<String>> FUNCTION = s -> new HashSet<>();
void method1(String key, String value) {
Function<String, Set<String>> func = s -> new HashSet<>();
mapOfSets.computeIfAbsent(key, func).add(value);
}
void method2(String key, String value) {
mapOfSets.computeIfAbsent(key, s -> new HashSet<>()).add(value);
}
void method3(String key, String value) {
mapOfSets.computeIfAbsent(key, FUNCTION).add(value);
}
}
Run Code Online (Sandbox Code Playgroud) 使用Spring
<bean id="id2" class="class2">
</bean>
<bean id="id1" class="class1">
<constructor-arg index="0" ref="id2" />
</bean>
Run Code Online (Sandbox Code Playgroud)
如果使用getbean("id1"),我发现不会自动创建id2.如何在创建id1之前强制创建id2?
我希望能够向我的方法添加弃用消息,以便在.class打开文件时显示弃用消息.理想情况下,此消息将用于将已编译类的用户定向到替换已弃用版本的方法.
源Java文件
/**
* @deprecated This is the message I want displayed in the complied code
*/
@Deprecated
public void someMethod(java.lang.String couponCode) {
this.x++;
}
Run Code Online (Sandbox Code Playgroud)
编译的类文件
下面的代码是我.class使用Intellij 12打开文件时当前显示的内容
/**
* @deprecated
*/
@java.lang.Deprecated
public void someMethod(java.lang.String couponCode) { /* compiled code */ }
Run Code Online (Sandbox Code Playgroud) 我想在每个月的第3个星期日发射扳机.在cron表达式中我使用了cron ="0 0 23?*1#3"但是它给了我Exception
java.lang.NumberFormatException: For input string: "1#3"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.valueOf(Unknown Source)
at org.springframework.scheduling.support.CronSequenceGenerator.getRange(CronSequenceGenerator.java:324)
at org.springframework.scheduling.support.CronSequenceGenerator.setNumberHits(CronSequenceGenerator.java:297)
at org.springframework.scheduling.support.CronSequenceGenerator.setDays(CronSequenceGenerator.java:275)
at org.springframework.scheduling.support.CronSequenceGenerator.parse(CronSequenceGenerator.java:241)
at org.springframework.scheduling.support.CronSequenceGenerator.<init>(CronSequenceGenerator.java:81)
at org.springframework.scheduling.support.CronTrigger.<init>(CronTrigger.java:54)
at org.springframework.scheduling.support.CronTrigger.<init>(CronTrigger.java:44)
at org.springframework.scheduling.config.ScheduledTaskRegistrar.afterPropertiesSet(ScheduledTaskRegistrar.java:188)
at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.onApplicationEvent(ScheduledAnnotationBeanPostProcessor.java:209)
at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.onApplicationEvent(ScheduledAnnotationBeanPostProcessor.java:1)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:324)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:929)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:467)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:384)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4765)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5260)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1525)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1515)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Run Code Online (Sandbox Code Playgroud)
这是我正在尝试的代码
@Scheduled(cron="0 0 …Run Code Online (Sandbox Code Playgroud) 我一直在努力找到为什么我的if陈述没有正常工作所以我用了一个try catch块代替.这是我所拥有的if语句:
//selectArtistByName returns an Artist object
if (!selectArtistByName(artist.getName()).equals(artist.getName()) ||
selectArtistByName(artist.getName())==null) {
//save data to database
}
Run Code Online (Sandbox Code Playgroud)
当我运行上面的内容时,我得到了一个,NullPointerException因为该方法在数据库为空selectArtistByName时返回null.我不明白的是为什么if当我得到它时它没有在声明中出现null.所以我做了这个并且它有效:
try {
if (!selectArtistByName(artist.getName()).equals(artist.getName())) {
}
} catch (NullPointerException e) {
m_db.insert(TABLE_ARTIST, null, artistContents);
}
Run Code Online (Sandbox Code Playgroud)
我不是Java大师,但它看起来像是一个可怕的修复程序.我怎么能解决这个问题.
我想知道为什么JDK 9不再有Java EE版本。我读到,由于 JDK 9 版本不再包含 Java EE,因此 Java EE 自己的功能将显示为已弃用。你知道如何解决这个问题吗?
是否可以仅使用 C++ 来制作 Android 应用程序?我不懂Java。我尝试过 Visual Studio 2019 方法,但我想我的计算机不足以模拟 Android 手机。
java ×8
spring ×2
android ×1
asp.net ×1
c++ ×1
deprecated ×1
events ×1
if-statement ×1
java-9 ×1
spring-mvc ×1