You should declare the sum and sum2 prior to the loop, the way you have

coded it will not accumulate, it doesn't even compile

Code:

import java.io.*;
public class PP2 {
public static void main(String[] args) throws IOException {
System.out.println("Enter the limit for sum:");
BufferedReader kbd = new BufferedReader(new InputStreamReader(System.in));
String S = kbd.readLine();
int loops = Integer.parseInt(S.trim());
int n;
double sum=0;
float sum2=0;
for (n = 1; n <= loops; n++) {
sum = sum + (double) (1 / n);
sum2 = sum2 + (float) (1 / n);
}
double condoub = sum - (double) Math.log(loops);
float conflout = sum2 - (float) Math.log(loops);
System.out.println("Euler's const, double: =" + condoub);
System.out.println("Euler's const, flout: =" + conflout);
}
}