Python到Java的转换问题

Python到Java的转换问题,java,python,Java,Python,我试着从Python转换成Java,但idk解释了为什么它不起作用 i = 0 e = input ('How much?') a = '' while not i == e: if i % 2 == 1 and i % 3 == 1 and i % 4 == 1 and i % 5 == 1 and i % 6 == 1 and i % 7 == 0: a = a +str(i)+',' i = i +1 print i else: i = i +1

我试着从Python转换成Java,但idk解释了为什么它不起作用

i = 0
e = input ('How much?')
a = ''
while not i == e:

if i % 2 == 1 and i % 3 == 1 and i % 4 == 1 and i % 5 == 1 and i % 6 == 1 and i % 7 == 0:
    a = a +str(i)+','
    i = i +1
    print i
else:
    i = i +1
    print i
   print 'Die Ergebnisse lauten:'
   print a
到爪哇

var i = 0;
var a = '';
var e = System.out.print("How much");

while (i !== e) {
 if (i % 2 == 1 & i % 3 == 1 & i % 4 == 1 & i % 5 == 1 & i % 6 == 1 & i % 7 == 0){
     a = a + System.out.print(i);
     i++;
     System.out.print(i);
   } else {
       i++;
       System.out.print(i);
    }
}
Idk怎么了

有人能帮我吗


谢谢

Java代码应该是这样的:

BufferedReader br = BufferedReader(new InputStreamReader(System.in));
int i = 0;
int e = Integer.parseInt(br.readline('How much?'));
String a = "";
while (i != e) {
 if ( i % 2 == 1 && i % 3 == 1 && i % 4 == 1 && i % 5 == 1 && i % 6 == 1 && i % 7 == 0) {
    a += i + ",";
    i++;
   System.out.println(i);
 } else {
   i++;
   System.out.println(i);
   System.out.println("Die Ergebnisse lauten:"); 
   System.out.println(a);
 }
}

如果有人看到任何问题,请对此进行评论,我会在手机上写下这篇文章。

一个符号和不是您想要的正确条件。使用
&
我注意到的第一件事是
而不是i==e:
比较值,但是
而(i!==e)
比较值和类型,不是
而(i!=e)
吗?注意Java 10添加了局部变量类型推断,并使用
var
作为关键字。上述内容可能是Java片段,而不是JavaScript。这对我来说是新的@markspace,谢谢@markspace但是
var a='
会创建一个字符,我想不是一个字符串。