Coder Social home page Coder Social logo

Comments (4)

eveliotc avatar eveliotc commented on May 21, 2024

In Java you declare a variable as final when you want to assign its value only once, attempting to reassign it will throw an exception at compile time. You may have noticed constants have this modifier, as per local variables/parameters means "I won't modify this variable reference/value during the flow of this method", normally you don't need it and is up to the code style.

from iosched.

bytebeats avatar bytebeats commented on May 21, 2024

@eveliotc
Yes, the value/reference of this variable declared as 'final' can't be changed or modified during the flow of this method. But what I wonder is, you know exactly, during the flow of this method, the Context and the boolean are not modified either. So, what the difference is here if the 'final's are erased?
Indeed, if there is a local inner class defined inside the method, in which parameters are used or changed, the 'final' is necessary. But there is no local inner class inside this method, so I figure 'final's here are unnecessary, what do you think?

from iosched.

eveliotc avatar eveliotc commented on May 21, 2024

@LittlePanpc yep, in that particular snippet is unnecessary

from iosched.

bytebeats avatar bytebeats commented on May 21, 2024

@eveliotc
OK, thank you very much.

from iosched.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.