Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
J

Jake86954

@Jake86954
About
Posts
8
Topics
4
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Missing '=' in if-statement
    J Jake86954

    No, 'i = 2' doesn't evaluate to 2, because this is not a valid comparison-statement (comparison-statements use '=='). So 'i = 2' is actually an an ASSIGNMENT and the if-statement seems to evaluate assignments to 'true', at least in Java.

    Clever Code learning

  • Missing '=' in if-statement
    J Jake86954

    My point is, the conditions 'myBool = false' and 'i=2' are both 'seen' as 'true' as far as the if-statement is concerned. In other words : if (myBool = false) { // This line will always be executed. } if (i = 2) { // This line will always be executed, even if i <> 2. // And, in fact, i will now be 2. }

    Clever Code learning

  • Missing '=' in if-statement
    J Jake86954

    Yes, it just sets the value of 'myBool' to False and after that, the complete statement is evaluated as true.

    Clever Code learning

  • Fun with Operators
    J Jake86954

    This is indeed perfectly correct Java-behaviour. I just added this example because less experienced users (who may not even know the difference between i++ and ++i) can be easily tricked by this.

    Clever Code

  • Missing '=' in if-statement
    J Jake86954

    Missing '=' in if-statement : if (myBool = false) // This if-statement will now always return 'true'. System.out.println("This line will now ALWAYS be executed !"); The correct syntax is, of course : if (myBool == false)

    Clever Code learning

  • Semicolon after if-statement
    J Jake86954

    Semicolon after if-statement : int a = 10; if(a == 2); // Bug ! There shouldn't be a semicolon here ! System.out.println("This line will now ALWAYS be executed !");

    Clever Code help

  • Fun with Operators
    J Jake86954

    Fun with Operators : int I = 6; I += I++; System.out.println("Result : " + I); // I is now 12 int I = 6; I += ++I; System.out.println("Result : " + I); // I is now 13

    Clever Code

  • assignment-bug
    J Jake86954

    assignment-bug : int myInt = 5; myInt =- 2; // Bug ! myInt is now -2 instead of the expected 3 ! Of course, the correct syntax is : myInt -= 2; // This makes myInt = 3.

    Clever Code help learning
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups