public class Main {
public static void main(String[] args) {
MyFunctionalInterface_1 F;
MyFunctionalInterface_2 G;
F = X::Method;
int i = F.Method(5);
System.out.println(i);
G = new X()::Method;
G.Method();
}
}
class X{
public static int Method(double x){
return (int)(x*x*x);
}
public void Method(){
System.out.println("Huy sosi");
}
}
@FunctionalInterface
interface MyFunctionalInterface_1{
int Method(double x);
}
@FunctionalInterface
interface MyFunctionalInterface_2{
void Method();
}
Run Code Online (Sandbox Code Playgroud)
我如何将函数称为F()或G()?
我在做考试题(俄语翻译):
在 Java 中编写实体声明 F、G 和 X,以便以下代码片段编译无错误
Run Code Online (Sandbox Code Playgroud)"F = X::Method; int i = F(0.0); G = …
我想为Credentials类创建一个单元测试,Calculate()它在执行方法后验证给定凭据的密码,它等于由实现IPasswordCalculator接口的对象计算的密码.
实际上,我创建的模拟对象string.Empty在调用Calculate(ICredentials)方法时返回值,而不是Pa$$w0rd,它将是所需的返回值.
然后...
Pa$$w0rd?提前致谢.
IPasswordCalculator接口
/// <summary>
/// The password calculator interface.
/// </summary>
public interface IPasswordCalculator
{
/// <summary>
/// Calculates the user password using
/// <paramref name="credentials"/> instance.
/// </summary>
/// <param name="credentials">
/// <see cref="ICredentials"/> to perform the calculation.
/// </param>
void Calculate(ICredentials credentials);
}
Run Code Online (Sandbox Code Playgroud)
ICredentials界面
/// <summary>
/// The Credentials interface.
/// </summary>
public interface ICredentials
{
/// …Run Code Online (Sandbox Code Playgroud) 随着风险陷入过于具体的问题......
给定用/ CLR编译的C++ MFC(混合,非抖动)项目,我已经定义了200个类.
当我为这个项目添加一个新的空类时,当我在调试模式下编译和执行时会出错.
未知模块中出现未处理的"System.IO.FileLoadException"类型异常.
附加信息:无法加载文件或程序集"ProjectA,Version = 0.0.0.0,Culture = neutral,PublicKeyToken = null"或其依赖项之一.无法找到或加载类型.(来自HRESULT的异常:0x80131522)
ProjectA是MFC项目本身的名称.没有ProjectA对项目配置上的任何程序集的引用,也没有对另一个自定义程序集的引用.
此项目仅引用某些.NET Framework程序集,以便允许项目中的某些自定义类可以使用CLR类.
然后,问题是......
编辑:
正如我在评论中所说,在发布模式下,编译成功没有错误.
此外,我清理,构建,清理,关闭Visual Studio,重新启动计算机......问题仍然出现.如果我保留200个班级,则没有错误.当我转到201时,出现错误.
目前我正在尝试在一个新的默认MFC项目中重现,添加类到达到200,以确认存在真正的限制.
编辑2:错误修复
感谢你们!