gXa's blog

By gXa, history, 9 years ago, In English

In java 8, all the commands of java 7 work or not.

I am asking this question because in c++ 11 #define tr(c,it) for(typeof(c.begin()) it=c.begin();it!=c.end();++it) does not work while in c++4.9.2 it works.

So I wanted to know which one is better java 8 or 7 and if java 8 then all commands of java 7 work on it or not. Plz help me in this.

  • Vote: I like it
  • -12
  • Vote: I do not like it

»
9 years ago, # |
  Vote: I like it +2 Vote: I do not like it

Why downvotes? I am just asking if all commands in java 7 can be used in java 8 or not. If u don't want to help, then ignore it.

  • »
    »
    9 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    Any java7 code would work at java8

»
9 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

The code sample you have given:

#define tr(c,it) for(typeof(c.begin()) it=c.begin();it!=c.end();++it)

can be written, in C++11, in an easier way:

#define tr(c,it) for(auto it=c.begin();it!=c.end();++it)

For the Java question: when in doubt, use Java 8.