for (int i = 5; i track.add(eventErzeugen(144,1,i,100,i)); track.add(eventErzeugen(176,1,127,0,i)); track.add(eventErzeugen(128,1,i,100,i + 2));
eclipse gives 5 errors, saying: Exception in thread "main" java.lang.Error: Unresolved compilation problems: i cannot be resolved to a variable My question is: what is wrong with the variable i??You are watching: Cannot be resolved to a variable java
author










posted 11 years ago


enri Fsfaed wrote: Exception in thread "main" java.lang.Error: Unresolved compilation problems: i cannot be resolved to a variable
Can you please give us the errors from the compiler? All that error is saying is ... "there were some compile errors, but it was ran anyway, and now we hit some invalid code"..... It is really not a good idea to run any code that has compile errors. Henryposted 11 years ago
See more: Quote By Bob Ross: “ We Don T Make Mistakes Just Happy Little Accidents
The for loop isn"t what you think it is - there is one very crucial character that you need to delete.
the compiler states
Exception in thread "main" java.lang.Error: Unresolved compilation problems: i cannot be resolved to a variable i cannot be resolved to a variable i cannot be resolved to a variable i cannot be resolved to a variable i cannot be resolved to a change at minimusikplayer2.MiniMusikPlayer2.los(MiniMusikPlayer2.java:25) at minimusikplayer2.MiniMusikPlayer2.main(MiniMusikPlayer2.java:9)
I will be thankfull for any support. Now I have to go but I will be back in 5 hours!!!
package minimusikplayer2; import javax.sound.midi.*; public class MiniMusikPlayer2 implements ControllerEventListener public static void main(String<> args) MiniMusikPlayer2 mini = new MiniMusikPlayer2(); mini.los(); public void los() try Sequencer sequencer = MidiSystem.getSequencer(); sequencer.open(); int<> gewuenschteEvents = 127 ; sequencer.addControllerEventListener(this, gewuenschteEvents); Sequence seq = new Sequence(Sequence.PPQ, 4); Track track = seq.createTrack(); for (int i = 5; i track.add(eventErzeugen(144,1,i,100,i)); track.add(eventErzeugen(176,1,127,0,i)); track.add(eventErzeugen(128,1,i,100,i + 2)); sequencer.setSequence(seq); sequencer.setTempoInBPM(220); sequencer.start(); Thread.sleep(5000); sequencer.close(); catch (Exception ex) ex.printStackTrace(); public void controlChange(ShortMessage event) System.out.println("la"); public MidiEvent eventErzeugen(int comd, int chan, int one, int two, int tick) MidiEvent event = null; try ShortMessage a = new ShortMessage(); a.setMessage(comd,chan,one,two); event = new MidiEvent(a, tick); catch (Exception e) return event; }