Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Igor Perrotta

IF not picking up the correct condition -JAVA-

Thanks for the replies guys, sorry for explaining badly what was going on, I was in a rush. but I was able to solve it, I was comparing a char with an int. I used Character.getNumericValue and the if was able to verify correctly! 

Recommended Posts

Posted · Original PosterOP

Hey everyone, how are you guys today? 

I'm doing a round robin scheduler and i've come across this problem.

The tempodeExecucao variable is in the correct amount and so does the cpu[0].vetordeIO as the screenshot shows. but it won't go into the if.

i need the verification to work so i can send the process on the queue.

thanks for the help!

if (cpu[0].vetorDeIO.length != 0) {
                    if (cpu[0].tempodeExecucao == cpu[0].vetorDeIO) {
                        System.out.println("OPERACAO IO");
                        System.out.println("NOME E TEMPO DE EXECUCAO " + cpu[0].getNome() + cpu[0].tempodeExecucao);
                        filaexecucao.enqueueProcess(cpu[0]);
                        cpu[0] = filaexecucao.dequeueProcess();
                    
                        break;

                    }
                }

unknown.png

Link to post
Share on other sites

i'm a bit confused as to whats going on here, since it looks like vetorDelO is some kind of collection based on the variable view there, but you are directly comparing it to the temposeExecucao, which looks like a numeric primitive, which shouldn't compile. More context in the code would help here.


Gaming build:

CPU: i7-7700k (5.0ghz, 1.312v)

GPU(s): Asus Strix 1080ti OC (~2063mhz)

Memory: 32GB (4x8) DDR4 G.Skill TridentZ RGB 3000mhz

Motherboard: Asus Prime z270-AR

PSU: Seasonic Prime Titanium 850W

Cooler: Custom water loop (420mm rad + 360mm rad)

Case: Be quiet! Dark base pro 900 (silver)
Primary storage: Samsung 960 evo m.2 SSD (500gb)

Secondary storage: Samsung 850 evo SSD (250gb)

 

Server build:

OS: Ubuntu server 16.04 LTS (though will probably upgrade to 17.04 for better ryzen support)

CPU: Ryzen R7 1700x

Memory: Ballistix Sport LT 16GB

Motherboard: Asrock B350 m4 pro

PSU: Corsair CX550M

Cooler: Cooler master hyper 212 evo

Storage: 2TB WD Red x1, 128gb OCZ SSD for OS

Case: HAF 932 adv

 

Link to post
Share on other sites

It seems like you forgot to access the 0th element of vetorDeIO, but that should usually give an error or warning.


My boring Github   /人◕ ‿‿ ◕人\

Link to post
Share on other sites

Second "if" statement, the `cpu[0].vetorDeIO` looks to be an array.

// cpu[0].vetorDeIO  => cpu[0].vetorDeIO[0]
// this
if (cpu[0].tempodeExecucao == cpu[0].vetorDeIO) {...
// to
if (cpu[0].tempodeExecucao == cpu[0].vetorDeIO[0]) {...
  

 

Link to post
Share on other sites
Posted · Original PosterOP · Best Answer

Thanks for the replies guys, sorry for explaining badly what was going on, I was in a rush. but I was able to solve it, I was comparing a char with an int. I used Character.getNumericValue and the if was able to verify correctly! 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×