Jump to content

[Tutorial] Learning Java with TRiBot #3 - Primitive Basics

Recommended Posts

Leaning Java with TRiBot - Primitive Basics

Click Here for a List of All Tutorials

If anyone would like to provide any advice or feedback on the tutorial, please message me on Skype. I want to keep the comments to questions as much as I possibly can, so people can learn not only by reading the tutorial, but also reading the rest of the thread. Thank you!


As always, be sure that you read every line of this tutorial carefully. If you don't, you are going to find yourself very lost. When I tell you to stop and think about something, I'd definitely recommend that you listen!

By now you should have read, and hopefully loosely understand, my 2nd tutorial. If you haven't, I would highly recommend doing so before reading this.

What is a Primitive?


Recall from my previous tutorial that Java is comprised of objects. Objects are created by classes, and controlled by methods. This is useful, of course, but what about much simpler ideas? What if you want to know something that is too simple to be an object, such as the height of a person? That is what primitives are for.

Types of Primitives

There are multiple types of primitives, but I am going to be focusing on only several of them in this tutorial. The rest are much less commonly used, and I will have a tutorial on them in the future. For now, let's just focus on the following.


As you have probably guessed, int is short for "integer".

An integer is a whole number. An integer can be positive, negative, or zero, but because it is a whole number, cannot ever be a fraction or decimal.

Integers are used when a decimal or fraction doesn't make sense. One of the most common ways to use an integer is when you are counting something. If you are counting something, you usually want to count in whole numbers. For example, how many trees are in this picture?


The answer is 3. There are 3 trees.

Now, I know what some of you might be thinking; "what if there is a half of a tree?". The answer to that is as follows: Don't think that way. Take the following picture for example.


While it's funny to say that there are 2.5 men here (the TV show reference which makes it even funnier), there are in fact 3 people in this picture. If you tell the computer that there are 2.5 people, the computer won't understand your humor, and will get incredibly confused and you will get a lot of nasty errors.

Another Example: If you are still confused as to why you might need a value that can't be a fraction of decimal, look at the top of your browser window. How many tabs are open? 1? 2? 10? I can bet you that the number of tabs open in your browser is an integer!

Aaaand Another Example: Sometimes integers aren't necessary, but they just make life easier. Take a look at your various skill XP values in RuneScape. Imagine how confusing it would be if you could have 32,392.382394 XP in a skill.


Remember when I said that ints can't be decimals or fractions? As I'm sure you guessed, doubles can be!

Doubles represent pretty much any number you can think of. If whatever you are trying to describe should be able to be a fraction or decimal, you should use a double.

Here are some examples of doubles: 3.4, 1.0, 1932.2, 2.2912992, -2.1, -3291, 0.0.

While integers are usually used to count things, doubles are most commonly used to define properties of things. These would be things like weight, height, the pull of gravity, etc.


A boolean has one of two values: true or false.

Booleans are sometimes the hardest primitive for people to understand the usefulness of. To help clarify things, I present to you the following educational image.


When you select someone as being "hot" or as being "not", you are selecting a boolean. Is this person hot? True or false? When you select your answer, the program sets a boolean to "true" or "false" depending on what you select.

Another Example: Open up pretty much any script on TRiBot that has a GUI. Chances are that there is at least one check box on that GUI. When you press "Start" on that GUI, the script will look at all of the check boxes and see if they are checked or not. How is this done? As you probably guessed, with a boolean!


You won't be using characters very often (even for advanced programs it isn't very common), but because of their uniqueness, I will mention them briefly.

Char stands for character. Characters are exactly that: characters. Anything on your keyboard is a character.

Here are some examples: 'A', 'B', 'C', 'G', 'a', 'b', ' ', '%', '~', etc.


This is the end of the third installment of my Learning Java with TRiBot tutorial series. This session was all about learning the basics of what primitives are in Java.

In the next tutorial, we will be diving right back into program structure!

As I mentioned in my previous tutorials, if people seem interested in this concept, I'll probably make videos to go along with my written tutorials as well!

Also, if there is anything listed above that you would like a graphical representation of so you can visualize it better, please let me know and I will do my best to include it.


If there is anything you don't understand, please let me know! If you didn't understand it, chances are someone else didn't either.

Click Here For Tutorial #4!

Edited by TacoManStan
  • Like 16

Share this post

Link to post
Share on other sites



Thank you for this! Found this more useful that any guide iv searched for on the web. Will you be basing this whole concept around tribot.. or just learning java in general?

The goal is to learn java through TRiBot (and RuneScape), so the guides will almost always be someone related to one of the two or both. That being said, these beginning tutorials are just going over Java fundamentals, so there won't be any TRiBot scripting, just Runescape references.

Share this post

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

  • Our picks

    • This update will:

      Fix GE inventory item positioning bug

      Fix broken object hooks
        • Like
      • 21 replies
    • This release will:

      Fix some ClosedChannelException bug

      Fix bug in RSObject#getAllTiles

      Add game tab support for "Kourend Favour"
        • Like
      • 15 replies
    • This release will:

      Fix Settings UI placement bug

      Fix game object location bug

      Fix small layout bug making the client shift up and down

      Fix client crashing bug where loading the client with a small display area will cause the client to crash

      Fix annoying Linux bug relating to painting events and peers

      Fix settings saving bug where settings are saved to disk more often than they should

      Fix RSInterface#isBeingDrawn bug affecting a limited amount of people

      Drop Java 1.7 bytecode version for 1.8

      Important: Since the downloadable RS client uses Java 7, it will no longer be compatible with Looking Glass. To make up for this, we will add support for using other clients such as RuneLite (at a later date).

      This change was necessary to allow us to use Java 8 syntax. It also paves the way for Java 9/10/11 support.
        • Like
      • 40 replies
    • This update will:

      Fix the RSMenuNode bug which also fixes the bug with bank opening

      Fix the incorrect object positions bug

      Fix and re-enable the LG Objects API Accelerator

      Fix the RSObject#getAllTiles bug
        • Like
      • 22 replies
    • Try our development release by checking "Development Release" on the TRiBot Loader. Note that these new features are currently in beta.

      This release features:

      Re-sizable mode support for both LG and the regular client

      Slightly improved login bot

      Removed final access modifiers from API classes

      Added RSServer hook wrapper to get the client's cached list of server/world info

      [NEW] Bug fix for intelligent banking

      [NEW] Improvement to the stability of LG over time

      [NEW] Vastly improved the reliability and speed of Screen#getColorAt on both LG and the regular client

      [NEW] Fix LG login problems

      [NEW] Fixed re-sizable mode container bug

      [NEW] Fixed re-sizable mode mouse bug

      [NEW] Use of public constants in the Banking API

      [NEW] Use of other various constants such as Projection#NULL_PT and Screen#EMPTY_COLOR

      More features to come very soon!

      Please test it and let us know here if there are any new bugs introduced in this release.
        • Thanks
        • Like
      • 12 replies
  • Recently Browsing   0 members

    No registered users viewing this page.