I am using the NetBeans IDE to run and compile Java.
This is a piece of code that I have made with C++.
I want to print out the variable i
when it's not the same as the value it's compared to. This is my C++ code:
#include <iostream>
#include <string>
int v[5000];
int main(void) {
int check_self = 0;
for(int i = 1; i < 5000; ++i) {
//output any value i that is not the same as v[i]
if(!(v[i])) std::cout << i << '\n';
check_self = i + (i%10) + (i/10)%10 + (i/100)%10 + (i/1000)%10;
v[check_self] = 1;
enter code here
}
return 0;
}
If I declare this in Java should it be like this?
int v[] = new int [5000];
When I tried to write: if ( ! v [ i ] )
, it shows an error. Is the way Java handles this different?