假设我们有以下类:
class A {
void recursive(int i) {
System.out.println("A.recursive(" + i + ")");
if (i > 0) {
recursive(i - 1);
}
}
}
class B extends A {
void recursive(int i) {
System.out.println("B.recursive(" + i + ")");
super.recursive(i + 1);
}
}
Run Code Online (Sandbox Code Playgroud)
现在让我们recursive在A班打电话:
public class Demo {
public static void main(String[] args) {
A a = new A();
a.recursive(10);
}
}
Run Code Online (Sandbox Code Playgroud)
正如预期的那样,输出从10减少.
A.recursive(10)
A.recursive(9)
A.recursive(8)
A.recursive(7)
A.recursive(6)
A.recursive(5)
A.recursive(4)
A.recursive(3)
A.recursive(2)
A.recursive(1)
A.recursive(0)
Run Code Online (Sandbox Code Playgroud)
让我们来看看令人困惑的部分.现在我们打电话给recursiveB班.
预期 …
我刚刚s在下面的lambda表达式中替换为_:
s -> Integer.parseInt(s)
Run Code Online (Sandbox Code Playgroud)
Eclipse编译器说:
'_'不应该用作标识符,因为它是源级别1.8的保留关键字.
我没有在JLS§3.9词汇结构/关键词中找到任何解释.
什么是Java 8的默认垃圾收集器?
当我检查JMX Beans时,他们将它显示为新一代的并行收集器和旧一代的旧串行收集器.
如何在查询中过滤,以便结果排除任何具有属于列表的ID的对象实例?
让我们说:
object_id_list = [1, 5, 345]
MyObject.objects.filter(Q(time__gte=datetime.now()) & Q( ... what to put here? ... ))
Run Code Online (Sandbox Code Playgroud)
一种风格的东西 "SELECT * FROM ... WHERE id NOT IN (...)"
在Android应用中实施应用内结算似乎相当复杂.我怎么能这样做?SDK中的示例应用程序只有一个Activity,这对于像我这样有多个Activity的应用程序来说过于简单了.
我有一个批处理文件,可以将文件从Visual Studio复制到我的Web文件夹.我想复制我的web项目中的所有文件,除了*.cs文件外.我似乎无法让这个工作:
xcopy /r /d /i /s /y /exclude:".cs" C:\dev\apan C:\web\apan
Run Code Online (Sandbox Code Playgroud)
有小费吗?当我尝试运行它时,我只得到退出代码4.
我有一个像这样的实体类:
@Entity
@Table(name = "EMAIL")
class Email{
@Id
@Column(name = "Id")
Long id;
@Column(name = "EMAIL_ID")
String emailId;
@Column(name = "PIN_CODE")
String pincode;
}
Run Code Online (Sandbox Code Playgroud)
如何findBy使用crudrepository spring data jpa为下面的查询编写方法?
select email_id,name from email_details where eamil_id in('mike@gmail.com','ram@gmail.com') and pin_code in('633677','733877')
Run Code Online (Sandbox Code Playgroud)
我期待像下面的spring数据jpa方法但是如何构造它?
List<Email> findBy.....(List<String> emails, List<String> pinCodes);
Run Code Online (Sandbox Code Playgroud)
我想在单个数据库命中中获取电子邮件列表.
给定一个整数数组A,N我们N在2D平面中绘制光盘,使得第i个光盘具有中心(0,i)和半径A[i].如果第k个和第j个盘具有至少一个公共点,我们说第k个盘和第j个盘相交.
写一个函数
int number_of_disc_intersections(int[] A);
Run Code Online (Sandbox Code Playgroud)
给出如上所述的A描述N盘的阵列,返回交叉盘对的数量.例如,给定N=6和
A[0] = 1
A[1] = 5
A[2] = 2
A[3] = 1
A[4] = 4
A[5] = 0
Run Code Online (Sandbox Code Playgroud)
共有11对交叉盘:
0th and 1st
0th and 2nd
0th and 4th
1st and 2nd
1st and 3rd
1st and 4th
1st and 5th
2nd and 3rd
2nd and 4th
3rd and 4th
4th and 5th
Run Code Online (Sandbox Code Playgroud)
所以函数应该返回11.如果相交对的数量超过10,000,000,函数应该返回-1.该函数可以假设N不超过10,000,000.
我正在使用带有jacoco插件的maven 来生成代码覆盖率指标.我有在配置一些困难神火由所需的Java插件的选项jacoco插件.我已经在Stack Overflow上看到了一些关于此问题的答案,但有些东西对我不起作用.
我有一个多模块项目,我的一个模块配置了surefire插件,如下所示:
foo/pom.xml:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-XX:MaxPermSize=512m</argLine>
</configuration>
</plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)
这按预期工作.
现在我想结合jacoco获取代码覆盖率的指标,所以我加了一个代码覆盖率配置文件,处理所有jacoco配置:
parent/pom.xml:
<profile>
<id>CodeCoverage</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>jacoco-initialize</id>
<goals><goal>prepare-agent</goal></goals>
<configuration>
<propertyName>surefire.argLine</propertyName>
</configuration>
...
</execution>
<executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
Run Code Online (Sandbox Code Playgroud)
它是在这里看到的是,如果代码覆盖率指定配置文件,然后jacoco插件配置为使用surefire.argLine属性,该属性用于配置argLine为万无一失插件.
然后我更新了foo模块的pom.xml文件,以使用jacoco插件生成的属性:surefire.argLine
foo/pom.xml:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>${surefire.argLine} -XX:MaxPermSize=512m</argLine> …Run Code Online (Sandbox Code Playgroud) 我正在阅读C++项目的代码,它包含以下形式的代码:
namespace ns {
class A {};
class B {};
}
struct C {
typedef ns::A* ns::B::* type;
};
Run Code Online (Sandbox Code Playgroud)
有人可以解释这条typedef线的含义吗?type似乎是某种指针的成员的ns::B指向ns::A,但我不知道.
类A和B实际代码不是空的,但我认为这与此无关.这是一个实例.