Alex Rivera | Logout

Variable naming conventions in Java

Asked 2009-01-05T18:15:31.930
23

In PHP, we (at least the good programmers) always start general variable names with a lower-case letter, but class variables/objects with an uppercase letter to distinguish them. In the same way we start general file names with a lower case letter, but files containing Classes with an upper case letter.

E.g.:

<?php
    $number = 123;
    $string = "a string";
    $colors_array = array('red', 'blue', 'red');
    $Cat = New Cat();
?>

Are the conventions the same in Java, i.e., objects starting with uppercase, but the rest with lowercase, or does everything start with lowercase as I've read in other places?

Edit
Report

1 Answer

4

The convention is that class names start with an uppercase letter. Variable names are lower camel case. Even if the variable references an object, it still starts with lower case.

This page should help.

answered 2009-01-05T18:18:16.433

Your Answer