Informatiker Board (http://www.informatikerboard.de/board/index.php)
- Themengebiete (http://www.informatikerboard.de/board/board.php?boardid=1)
--- Theoretische Informatik (http://www.informatikerboard.de/board/board.php?boardid=5)
---- formale Sprachen (http://www.informatikerboard.de/board/board.php?boardid=12)
----- Eclipse Error (http://www.informatikerboard.de/board/thread.php?threadid=1058)


Geschrieben von Lisa23 am 01.11.2011 um 11:35:

  Eclipse Error

Hallo,
public static void main(String[] args) {
int n = 25;
int s = 0;
int k = 1;
while ( k < n ) {
s += 2*k-1;
k++;
}
weiss jmd vielleicht wieso dieser Befehl in Eclipse nicht funktioniert er sagt mir als Fehler :
The Value of The Local Variable S is Not Used aus
was amche ich falsch ?


MFG
Lisa



Geschrieben von Karlito am 01.11.2011 um 19:19:

 

Hi

es handelt sich um eine Warnung, da du s zwar neu belegst, aber nie für irgendwas benutzt. Wenn du im Anschluss noch s ausgibst, dann verschwindet diese Warung. S. u.

code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
public class Test {
	public static void main(String[] args) {
		int n = 25;
		int s = 0;
		int k = 1;
		while ( k < n ) {
		s += 2*k-1;
		k++;
		}
		
		System.out.println(s);
	}
}


VG,

Karlito


Forensoftware: Burning Board, entwickelt von WoltLab GmbH