Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By KevinWorkman

Thread: add integer value on each run

  1. #1
    aconti is offline Member
    Join Date
    May 2011
    Posts
    39
    Rep Power
    0

    Default add integer value on each run

    Hi,

    I would like to keep an variable integer value run after run which means;

    first I declare int x = 0;

    first program run it starts with 0 then becomes 5

    I want that the second run x starts from 5

    Thanks!

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,001
    Rep Power
    10

    Default

    Why don't you just write it to a file?
    Dark likes this.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default

    As far as I know, you would need to store it to a file and then on every run read it from that file to get your X. Then you would have to see if that file actually exists, if it doesn't then set x to 0 instead. Then if it doesn't exist, you would have to create the file so you could put your end result in it.
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

  4. #4
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    Do I hear a Properties file calling?

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

Similar Threads

  1. Big integer
    By penguinSlack in forum New To Java
    Replies: 1
    Last Post: 03-14-2011, 05:08 AM
  2. convert unsigned integer to signed integer in java?
    By diskhub in forum New To Java
    Replies: 6
    Last Post: 05-17-2010, 01:50 AM
  3. Hex to Integer Problem
    By Tempspec in forum New To Java
    Replies: 0
    Last Post: 04-01-2010, 12:14 PM
  4. How to convert Integer[] to int[]
    By Nithya in forum New To Java
    Replies: 26
    Last Post: 02-11-2010, 06:41 PM
  5. Integer vs int
    By bugger in forum New To Java
    Replies: 1
    Last Post: 11-14-2007, 10:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •