0

I recently started Android development(also JAVA is new to me) and would like to know the class naming convention in Android Java.

Considering the following class General class definition here

public final class Class

Toast class here

Toast toast = Toast.makeText(context, text, duration);

I found some example code where class is named as

Class mClass

What is the commonly followed naming convention in Android Java?

Also what does m stand for in mClass?

  • 1
    Search the StackOverflow before posting such a question. https://stackoverflow.com/questions/2092098/why-do-most-fields-class-members-in-android-tutorial-start-with-m – Rudrik Patel Oct 08 '20 at 11:35

1 Answers1

1

These are Google's intern naming convention! You don't have to follow these, if you don't want to. There is nothing right or wrong about them. Naming conventions are to follow, when you work together with other programmers in a team. They are a method to structure code, written by multiple programmers.

Google's Field naming convention:

  • Non-public, non-static field names start with 'm'.
  • Static field names start with 's'.
  • Other fields start with a lower case letter.
  • Public static final fields (constants) are ALL_CAPS_WITH_UNDERSCORES

Basically every company/programmer has there own way to name variables, classes, etc. Find what suites you the best!