Jump to content

Basic Java Notes


Juggles

Recommended Posts

These are the notes I wrote down when I was first learning java.
These are just the basics and should help set a foundation for you. 

It is crucial to understand these basics because they are used in every script.

 

I took these notes while doing Code Academy

 

f9c1b5bc654a76dd67f1f65615483531.png

db68e881e85461062750a12bba291044.png

39b50f35d5e581cfda9fd2544446f18d.png

 

** On the Order of Operation part, it is best to use parenthesis instead of following the guidelines because it can get confusing. 

Edited by Juggles
  • Like 15
Link to comment
Share on other sites

Most programmers avoid order of operations by forcing parenthesis to ensure the order is correct. Typical mistake:

bool1 || bool2 && bool3

Some people might think it's evaluating (bool1 || bool2) && bool3 when it's really bool1 || (bool2 && bool3).

Yeah I agree. I'll edit the notes and post that later. When I was first learning how to script, I didn't fully understand how to do order of operation so using the parenthesis is a better way to do it. 

Edited by Juggles
Link to comment
Share on other sites

  • 5 weeks later...
  • 1 month later...
  • 2 weeks later...
  • 3 weeks later...

Expanding upon what @Alek mentioned short circuit operators are fantastic for making code optimizations in conditions that depend on or's. Do your lightweight checks first (boolean state, etc.) so if any evaluate to true the condition will terminate early and not have to do any of your more robust calculations.

They're also a great place to chain calls together vs nested if's. Example RuneScape script case case:

!isPlayerInCombat() && playerHealth() > 20 && ((distanceToTarget > 10 && stepTowardsTarget) || attackTarget)

would be a perfect one statement generic method for attacking an entity that could be called each script poll.

  • Like 1
Link to comment
Share on other sites

  • 5 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...