小编Emb*_*ler的帖子

Java 9没有类定义异常

所以我想尝试http客户端

package com.company;

import jdk.incubator.http.HttpClient;

public class Main {

public static void main(String[] args) {
    HttpClient client =  HttpClient.newHttpClient();

  }
}
Run Code Online (Sandbox Code Playgroud)

我的模块信息看起来像这样

module com.company {
    requires jdk.incubator.httpclient;
}
Run Code Online (Sandbox Code Playgroud)

但我明白了 java.lang.NoClassDefFoundError: jdk/incubator/http/HttpClient

我真的不明白为什么.我的java版本是"build 9-ea + 169",我使用最新版本的IntelliJ idea(2017.1.3).我查看了这个答案,看起来我只需要将需求添加到文件中,但由于某种原因它不起作用.

java java-9 java-http-client

11
推荐指数
2
解决办法
2726
查看次数

两个变量的类实例

我是Haskell的新手并且创建了这个类

class Printable a where 
    toString :: a -> String
Run Code Online (Sandbox Code Playgroud)

还有两个例子

instance Printable Bool where
    toString x | x == True = "true"
               | x == False  = "false" 

instance Printable () where
    toString x = "unit type"
Run Code Online (Sandbox Code Playgroud)

它们工作得很好,现在我想创建一个带有两个参数的实例,但是我遇到了麻烦.到目前为止我创造的是

instance (Printable a, Printable b) => Printable (a, b) where
    toString x | fst x == True = "(true,unit type)"
Run Code Online (Sandbox Code Playgroud)

但现在我得到了错误

无法将预期类型'a'与实际类型'Bool'匹配

这是合理的,但是当我替换aBoolI时也会出错.我怎样才能使它在首位的工作,我可以限制类型ab-例如,如果我想要的东西a永远是Boolb永远是()?

haskell

2
推荐指数
1
解决办法
71
查看次数

标签 统计

haskell ×1

java ×1

java-9 ×1

java-http-client ×1