Author Topic: Writing Java code with humor  (Read 3022 times)

gotty

  • Developer & Maintainer
  • Administrator
  • Member
  • *****
  • Posts: 120
    • View Profile
    • Hedgecode Development
Writing Java code with humor
« on: 08:09:49, 14 Jan 2018 »
Code: java
/**
 * This program will sort the word "typewriter" in aphabetical order.
 */

public class SortingString {
    public static void main(String[] args)
    {
        String s = "typewriter";
        for (int i = 0; i < Integer.MAX_VALUE; i++)
        {
            s = randomSort(s);
           
            if (s.equals("eeiprrttwy"))
            {
                System.out.println(s);
                break;
            }
           
            if (i == Integer.MAX_VALUE - 1)
            {
                i = 0;
            }
        }
    }
    ...
}

« Last Edit: 08:51:02, 14 Jan 2018 by gotty »

gotty

  • Developer & Maintainer
  • Administrator
  • Member
  • *****
  • Posts: 120
    • View Profile
    • Hedgecode Development
Re: Writing Java code with humor
« Reply #1 on: 08:29:00, 14 Jan 2018 »
Doing conditionals:
Code: java
/* 1. Beginner level */
    if (condition) {...}

/* 2. Intermediate level */
    if (condition == true) {...}

/* 3. Advanced level */
    if (String.valueOf(condition).equals("true") {...}
« Last Edit: 08:51:28, 14 Jan 2018 by gotty »