• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to be a human compiler

 
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i need to find out if its working
if its not working thatn what kind of bug i will get
and how to fix it???

i need to find it by myself with pen and paper
anyone can suggest a system to solve this question

it is very complicated for me
i am looking for a way of simplification

[ February 15, 2008: Message edited by: donaldth smithts ]
 
Marshal
Posts: 79277
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is that exactly what you have been given? Are you sure you have copied it correctly?

I am afraid you are going to have to get a very large sheet of paper and a very sharp pencil. Good luck!

Start with the entry point (main) and write down this sort of thing:
  • declare len and i
  • declare arr
  • set len to 10
  • set arr to new int[len]
  • Start for loop with . . .
  • There, I've done the easy bit for you, now you can do the interesting bit.
     
    Ranch Hand
    Posts: 132
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    "The Human Compiler" - This is a very good skill to have which can save you endless amounts of time in the future. The best way to develop this skill is to close your IDE and start writing code in a text-editor. At least when you are starting off or learning a new language.
     
    Ranch Hand
    Posts: 457
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Lots of time spent writing and debugging code is the best way to hone this skill. There's no shortcut.
     
    alex lotel
    Ranch Hand
    Posts: 191
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    there is some method i found called Trace table

    http://en.wikipedia.org/wiki/Trace_table

    but its realy hard for me to build it when you make
    operations like Super()
    or


    by the way which what is the value of c in this case
    from what integer it takes the value??
     
    Ranch Hand
    Posts: 1683
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    The local variable d is always the one to be accessed by default in the method. If you wish to use the instance variable, you would have to code

    this.d

    .

    Incidentally, I never use the same variable names for instance and local variables, it avoids confusion
     
    alex lotel
    Ranch Hand
    Posts: 191
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    what is the local variable(i am a little weak in english)

    there is the variable wich is given as the input of the method
    and there is the variable which is a part of "this"
    what did you meam??
    so the answer is 8???

    about my question:
    its realy hard for me to build a table when it when you make
    operations like Super()
    or some other stuff

    the example which i showed in the link

    http://en.wikipedia.org/wiki/Trace_table
    [ February 16, 2008: Message edited by: donaldth smithts ]
     
    Roger Chung-Wee
    Ranch Hand
    Posts: 1683
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    A local variable is declared in the method, including the parameter list. So, both d and c are local variables.

    Contrast this with the first d which is an instance variable, which means that it is a member of the instance of the class. The this keyword refers to the current instance. So,this.d refers to the instance d variable.
     
    Rancher
    Posts: 280
    VI Editor C++ Debian
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by donaldth smithts:



    Not sure what Java's specification for integer overflow are, so this is either an infinite loop, or a V E R Y L O N G loop.
     
    alex lotel
    Ranch Hand
    Posts: 191
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    there codes like that:
    it differs alot from the example i showed in the link
    how am i supposed to build a table for this case
    there are so many stuff like "super" "this" different kinds of variables
    which have the same name
    how to solve it using the system i showed??
     
    Ranch Hand
    Posts: 490
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Roger Chung-Wee:
    The local variable d is always the one to be accessed by default in the method. If you wish to use the instance variable, you would have to code .

    Incidentally, I never use the same variable names for instance and local variables, it avoids confusion



    I disagree, using a different local variable name that is going to be assigned to an instance variable adds confusion.

    Variable names should be descriptive. Why waste time and energy coming up with a synonym?
     
    Rusty Shackleford
    Ranch Hand
    Posts: 490
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator



    public B(int a, int b)
    {
    this(a);
    a=b;
    }



    Hopefully you can spot syntax errors, for logical issues, just think it through.

    What does a=b mean in this context and does it make any sense whatsoever? If no, then what are the options available? And which one is likely the correct one. I see two possibilities: 1. delete a=b since it does absolutely nothing useful. 2. Assign b to the instance variable named a. What makes more sense.

    Context is everything. The next constructor also has a=b, is this a problem?
     
    alex lotel
    Ranch Hand
    Posts: 191
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    there codes like that:
    it differs alot from the example i showed in the link
    how am i supposed to build a table for this case
    there are so many stuff like "super" "this" different kinds of variables
    which have the same name
    how to solve it using the system i showed??
     
    author & internet detective
    Posts: 41878
    909
    Eclipse IDE VI Editor Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Rusty Shackleford:
    Variable names should be descriptive. Why waste time and energy coming up with a synonym?


    I agree that variable names should be descriptive. Conventions help though. If I always "_name" as my synonym, I haven't wasted any time or energy thinking of it.
     
    Rusty Shackleford
    Ranch Hand
    Posts: 490
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by donaldth smithts:
    there codes like that:
    it differs alot from the example i showed in the link
    how am i supposed to build a table for this case
    there are so many stuff like "super" "this" different kinds of variables
    which have the same name
    how to solve it using the system i showed??



    Do you understand what super and this are for?

    Read up on instance variables, local variables and scope.
     
    alex lotel
    Ranch Hand
    Posts: 191
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    i know what supr and this are for.
    i am looking for a sistematic way to solve it(show whats gonna be the out put of such code) using a table??

    can someone show me how to do that??
     
    alex lotel
    Ranch Hand
    Posts: 191
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    this is a typical code from an exam
    ican hold in my head every little thing
    i dont know how to organize the data

    can some one solve this code
    and show me how did he do it??
    how to follow the sequense of the code using pen and paper
    ??
     
    Ever since I found this suit I've felt strange new needs. And a tiny ad:
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic