Jump to content

Java Guide / Java Data And Variables.


Recommended Posts

 

 

6wItAcC.png

 

 

Java Data and Variables

 

There are 8 primitive data types. he 8 primitive data types are numeric types. The names of the eight primitive data types are:

 

byte short int long float double char boolean

There are both integer and floating point primitive types. Integer types have no fractional part; floating point types have a fractional part. On paper, integers have no decimal point, and floating point types do. But in main memory, there are no decimal points: even floating point values are represented with bit patterns. There is a fundamental difference between the method used to represent integers and the method used to represent floating point numbers. 

 

 

7wxrbU8.png

 

 


Examples

 

int yr = 2006;

double rats = 8912 ;

 

         For each primitive type, there is a corresponding wrapper class. A wrapper class can be used to convert a primitive data value into an object, and some type of objects into primitive data. The table shows primitive types and their wrapper classes:

 

 

qtZkbI7.png

 

 

Variables only exist within the structure in which they are defined. For example, if a variable is created within a method, it cannot be accessed outside the method. In addition, a different method can create a variable of the same name which will not conflict with the other variable. A java variable can be thought of as a little box made up of one or more bytes that can hold a value of a particular data type:

 

Syntax: variabletype variablename = data;

 

Source Code ( demonstrating declaration of a variable )



class example
{
  public static void main ( String[] args )
  {
    long x = 123;    //a declaration of a variable named x with a datatype of long


    System.out.println("The variable x has: " + x );
  }
}



Source Code



public class MaxDemo {
     public static void main(String args[]) {
     //integers
          byte largestByte = Byte.MAX_VALUE;
          short largestShort = Short.MAX_VALUE;
          int largestInteger = Integer.MAX_VALUE;
          long largestLong = Long.MAX_VALUE;




         //real numbers
         float largestFloat = Float.MAX_VALUE;
         double largestDouble = Double.MAX_VALUE;



       //other primitive types
        char aChar = 'S';
        boolean aBoolean = true;



        //Display them all.
        System.out.println("largest byte value is " + largestByte + ".");
        System.out.println("largest short value is " + largestShort + ".");
        System.out.println("largest integer value is " + largestInteger + ".");
        System.out.println("largest long value is " + largestLong + ".");
        System.out.println("largest float value is " + largestFloat + ".");
        System.out.println("largest double value is " + largestDouble + ".");
   }
}



 


Sample Run

 

The largest byte value is 127.

The largest short value is 32767.

The largest integer value is 2147483647.

The largest long value is 9223372036854775807.

The largest float value is 3.4028235E38.

The largest double value is 1.7976931348623157E308.

 

 

Dear Baggos mentioned on my previous post that a guide related to variables would be nice so here it is :)

Thanks.

 

  • Upvote 1
Link to comment
Share on other sites

Link to comment
Share on other sites

 

Im gettin blind  :happyforever:

Link to comment
Share on other sites

vampir only said than

if (condition)
{
  _var = 1;
}
else
{
   _var = 2;
}

could be replaced by

if (condition)
   _var = 1;
else
   _var = 2;

and even more sexier by

_var = (condition) ? 1 : 2;
Edited by Tryskell
Link to comment
Share on other sites

 

vampir only said than

if (condition)
{
  _var = 1;
}
else
{
   _var = 2;
}

could be replaced by

if (condition)
   _var = 1;
else
   _var = 2;

and even more sexier by

_var = (condition) ? 1 : 2;

 

I like the way you think XD

Link to comment
Share on other sites

I like the way you think XD

 

See a real case scenario of "if/else if" shortcuted here (fighter / mage buffs) : 

 

http://www.maxcheaters.com/topic/211475-newbies-helper-npc-acis/?p=2611476

 

As you can see, that idiom

(check) ? trueStatement : falseStatement

 can reduce redundant code for the same output.

Edited by Tryskell
Link to comment
Share on other sites

See a real case scenario of "if/else if" shortcuted here (fighter / mage buffs) : 

 

http://www.maxcheaters.com/topic/211475-newbies-helper-npc-acis/?p=2611476

 

As you can see, that idiom

(check) ? trueStatement : falseStatement

 can reduce redundant code for the same output.

 

Yea i have alot to improve thanks for showing me the way :) thats a way to shorten the code also make the code easier to read and understand.

Edited by Sawadee
Link to comment
Share on other sites

http://www.freejavaguide.com/java_variables.htm

 

Im dying laughing over here.

 

Nice u diged internet to find what i shared, but i didnt even know that this guide was posted on somewhere as i mentioned before i just copy and paste this guide from a pdf file that i found in my pc thats simple theres no need to tryhard :) The difference between me and you, you just break balls and do actually nothing for this community and i try to help with anythin/whatever i have/can.

Link to comment
Share on other sites

Nice u diged internet to find what i shared, but i didnt even know that this guide was posted on somewhere as i mentioned before i just copy and paste this guide from a pdf file that i found in my pc thats simple theres no need to tryhard :) The difference between me and you, you just break balls and do actually nothing for this community and i try to help with anythin/whatever i have/can.

Exquse me but you just got pwned. http://www.maxcheaters.com/topic/203773-free-help-small-code-fixes-request-small-codes/

Also continue this "speech". Next time you're reported for share guides without credits and bad language toward members. 

Link to comment
Share on other sites

Exquse me but you just got pwned. http://www.maxcheaters.com/topic/203773-free-help-small-code-fixes-request-small-codes/

Also continue this "speech". Next time you're reported for share guides without credits and bad language toward members. 

 

Bad language toward members? u should be banned for trolling and spammin on other people guides all the time i already reported you 3 times and im goin to do it again lets see who will be banned. stop acting like a lawyer u are just a simple member here mind your own business if anything is wrong with me ill be punished if anything is wrong with you, you will be punished just for gods sake stop posting on other topics and judge the people like your are their boss.

Edited by Sawadee
Link to comment
Share on other sites

Bad language toward members? u should be banned for trolling and spammin on other people guides all the time i already reported you 3 times and im goin to do it again lets see who will be banned. stop acting like a lawyer u are just a simple member here mind your own business if anything is wrong with me ill be punished if anything is wrong with you, you will be punished just for gods sake stop posting on other topics and judge the people like your are their boss.

You can't report someone who just tell you that you sharing tutorials without adding credits and going against rules. What you gonna report me for? 

"This user flame my topic and force me to put credits on stolen tutorials?" 

 

I don't flame, i just say you go against rules and leech other's tutorials. You dont want understand it? Report me as many times you want but read rules and we see who is wrong and who is right.

Link to comment
Share on other sites

You can't report someone who just tell you that you sharing tutorials without adding credits and going against rules. What you gonna report me for? 

"This user flame my topic and force me to put credits on stolen tutorials?" 

 

I don't flame, i just say you go against rules and leech other's tutorials. You dont want understand it? Report me as many times you want but read rules and we see who is wrong and who is right.

 

I didnt even read anything ill be honest, lets see what will be the action of admin/moderators about us.

Link to comment
Share on other sites

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.



  • Posts

    • 2 Factor Authentication Code for 100% secure login. Account provided with full information (email, password, dob, gender, etc).
    • ready server for sale, also available for testing with ready and beautiful npc zone pvp with custom 2 epic core orfen lvl2 with all maps ready all quests work at 100% ready comm  board with buffer teleport gm shop service anyone interested send me a pm many more that I forget  Exp/Sp : x30 (Premium: x40)    Adena : x7 (Premium: x10)   Drop : x7 (Premium: 10)   Spoil : x7 (Premium: 10)   Seal Stones : x7 (Premium: 10)   Raid Boss EXP/SP : x10   Raid Boss Drop : x3 (Premium: x5)   Epic Boss Drop : x1 Enchants   Safe Enchant : +3   Max Enchant : +16   Normal Scroll of Enchant Chance : 55%   Blessed Scroll of Enchant Chance : 60% Game Features   GMShop (Max. B-Grade)   Mana Potions (1000 MP, 10 sec Cooldown)   NPC Buffer (Include all buffs, 2h duration)   Auto-learn skills (Except Divine Inspiration)   Global Gatekeeper   Skill Escape: 15 seconds or /unstuck   1st Class Transfer (Free)   2nd Class Transfer (Free)   3rd Class Transfer (700 halisha mark)   Subclass (Items required from Cabrio / Hallate / Kernon / Golkonda + Top B Weapon + 984 Cry B)   Subclass 5 Subclasses + Main (Previous subclasses to level 75 to add new one)   Noblesse (Full Retail Quest)   Buff Slots: 24 (28 with Divine Inspiration LVL 4)   Skill Sweeper Festival added (Scavenger level 36)   Skill Block Buff added   Maximum delevel to keep Skills: 10 Levels   Shift + Click to see Droplist   Global Shout & Trade Chat   Retail Geodata and Pathnodes   Seven Signs Retail   Merchant and Blacksmith of Mammon at towns   Dimensional Rift (Min. 3 people in party to enter - Instance)   Tyrannosaurus drop Top LS with fixed 50% chance   Fast Augmentation System (Using Life Stones from Inventory)   Chance of getting skills (Normal 1%, Mid 3%, High 5%, Top 10%)   Wedding System with 30 seconds teleport to husband/wife Olympiad & Siege   Olympiad circle 14 days. (Maximum Enchant +6)   Olympiads time 18:00 - 00:00 (GMT +3)   Non-class 5 minimum participants to begin   Class based disabled   Siege every week.   To gain the reward you need to keep the Castle 2 times. Clans, Alliances & Limits   Max Clients/PC: 2   Max Clan Members: 36   Alliances allowed (Max 1 Clans)   24H Clan Penalties   Alliance penalty reset at daily restart (3-5 AM)   To bid for a Clan Hall required Clan Level 6 Quests x3   Alliance with the Ketra Orcs   Alliance with the Varka Silenos   War with Ketra Orcs   War with the Varka Silenos   The Finest Food   A Powerful Primeval Creature   Legacy of Insolence   Exploration of Giants Cave Part 1   Exploration of Giants Cave Part 2   Seekers of the Holy Grail   Guardians of the Holy Grail   Hunt of the Golden Ram Mercenary Force   The Zero Hour   Delicious Top Choice Meat   Heart in Search of Power   Rise and Fall of the Elroki Tribe   Yoke of the Past     Renegade Boss (Monday to Friday 20:00)   All Raid Boss 18+1 hours random respawn   Core (Jewel +1 STR +1 DEX) Monday, Wednesday and Friday 20:00 - 21:00 (Maximum level allowed to enter Cruma Tower: 80)   Orfen (Jewel +1 INT +1 WIT) Monday to Friday, 20:00 - 21:00 (Maximum level allowed to enter Sea of Spores: 80)   Ant Queen Monday and Friday 21:00 - 22:00 (Maximum level allowed to enter Ant Nest: 80)   Zaken Monday,Wednesday,Friday 22:00 - 23:00 (Maximum level allowed to enter Devil's Isle: 80)   Frintezza Tuesday, Thursday and Sunday 22:00 – 23:00 (Need CC of 4 party and 7 people in each party min to join the lair, max is 8 party of 9 people each)   Baium (lvl80) Saturday 22:00 – 23:00   Antharas Every 2 Saturdays 22:00 - 23:00 Every 2 Sundays (alternating with Valakas) 22:00 – 23:00   Valakas Every 2 Saturdays 22:00 - 23:00 Every 2 Sundays (alternating with Antharas) 22:00 – 23:00   Subclass Raids (Cabrio, Kernon, Hallate, Golkonda) 18hours + 1 random   Noblesse Raid (Barakiel) 6 hours + 15min random   Varka’s Hero Shadith 8 hours + 30 mins random (4th lvl of alliance with Ketra)   Ketra’s Hero Hekaton 8 hours + 30 mins random (4th lvl of alliance with Varka)   Varka’s Commander Mos 8 hours + 30 mins random (5th lvl of alliance with Ketra)   Ketra’s Commander Tayr 8 hours + 30 mins random (5th lvl of alliance with Varka)
    • Have a great day! Unfortunately, we can not give you the codes at the moment, but they will be distributed as soon as trial is back online, thanks for understanding! Other users also can reply there for codes, we will send them out some time after.
    • Ok mates i would like to play a pridestyle server (interluide, gracie w/ever) Is there any such server online and worth playing?
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock