有没有办法创建表单的for循环
for(int i = 0; i < 9; ++i) {
for(int j = 0; j < 9; ++i) {
//...
for(int k = 0; k < 9; ++k) { //N-th loop
Run Code Online (Sandbox Code Playgroud)
在编译时不知道N. 理想情况下,我试图找出一种循环通过数字向量的单独元素的方法,以便在用不同的数字替换一定数量的数字时创建每个可能的数字.
我正在尝试在java中的项目上运行SonarQube.我配置了声纳属性文件并将其放在项目目录中.在运行sonar.bat时,会出现一个错误,要求定义必需参数.起初我认为我的属性文件是错误的,但我已经尝试了我能想到的一切.
这是当前的属性文件
# Required metadata
sonar.projectKey=_newtest2
sonar.projectName=NoSqlDataModeling
sonar.projectVersion=2.0
# Path to the parent source code directory.
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# Since SonarQube 4.2, this property is optional if sonar.modules is set.
# If not set, SonarQube starts looking for source code from the directory containing
# the sonar-project.properties file.
sonar.sources=D:/eclipse workspace/NoSqlDataModeling
#Comma-separated paths to directories containing the binary files (directories with class files, in the case of Java).
sonar.binaries=D:/eclipse …Run Code Online (Sandbox Code Playgroud) 我们知道如果发生任何错误或任何未经检查的异常,那么我们的程序将停止,那么它们之间有什么区别?
虽然我有一些Java经验,但下面的代码对我来说有点奇怪:
public class ForLoopTest{
public static void main(String[] args){
for(;;){}
}
}Run Code Online (Sandbox Code Playgroud)
虽然初始化测试增量部分是空的,但是这个代码编译得很好,这与通常的for循环不同:
for(int i=0; i<10; i++){}
Run Code Online (Sandbox Code Playgroud)
由于代码编译很好,它是有效的语法.
这种类型的for循环有没有实际用途,没有初始化测试增量部分?
我想定义一个这样的时间界面:
public interface TimeInterface<T>
{
static T ZERO;
static T INFINITY;
// some other methods...
}
Run Code Online (Sandbox Code Playgroud)
这可能,或如何做到这一点,以避免错误?
提前致谢!
我正在使用biopython包,我想像tsv文件一样保存结果.这个输出从print到tsv.
for record in SeqIO.parse("/home/fil/Desktop/420_2_03_074.fastq", "fastq"):
print ("%s %s %s" % (record.id,record.seq, record.format("qual")))
Run Code Online (Sandbox Code Playgroud)
谢谢.
当我向pom.xml文件添加依赖项并使用"mvn package"构建时,Maven采用该依赖项代码采取了哪些步骤?
它是否物理地从该依赖项的包中获取java代码并将其放入JAR中?为什么我需要添加依赖...为什么Maven不能只查看我的import语句和完全限定名称并找出我需要哪些依赖项?
class test {
public static void main(String[] args) {
new test();
}
void method() {
class inside {
int a;
void methodinside() {}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用反射声明类:
Class c = Class.forName("test");
Class[] cls = c.getDeclaredClasses();
for(Class cl : cls)
System.out.println(cl.getName());
Run Code Online (Sandbox Code Playgroud)
但是,我的程序找不到class inside.
假设我有两个接口:
interface IOne {
public void method();
}
Run Code Online (Sandbox Code Playgroud)
和
interface ITwo {
public void method();
}
Run Code Online (Sandbox Code Playgroud)
具体类实现了两个接口:
public class A implements IOne, ITwo {
public void method(){
//some implementation
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是:
method()对于接口IOne和ITwo ,单个实现是否足够?Java类中常见的有许多getter和setter方法,每个方法对应一个数据模型类变量.我意识到很多IDE会为你创建这些,但是我试图避免这种混乱,并且在我的课程中没有所有这些方法.那么,有没有办法以类外的只读方式访问变量(就好像它是公共最终的),同时保留了类或子类内的写访问权限(就好像它是私有的或受保护的).
我提出的唯一伪解决方案是基类(或具有默认方法的接口),它具有get(String variableName)方法,然后通过反射获取类的字段并返回适当的字段.缺点是,为了工作,变量必须是公共的,所以只有按照惯例它才符合我的要求(在扩展/实现类中有我想要访问的变量,我只调用get方法在类之外,并没有实现set方法).我不喜欢的主要问题是,如果变量名称发生变化,get方法的调用者将不会导致编译器错误,因为变量名称只是一个硬编码的String.
谁有更好的主意?