with one click
java
// Google's official Java style guide. Covers 2-space indentation, 100-char line limit, naming conventions, braces, imports, Javadoc, exception handling, lambdas, and streams. Enforces @Override annotations and specific imports.
// Google's official Java style guide. Covers 2-space indentation, 100-char line limit, naming conventions, braces, imports, Javadoc, exception handling, lambdas, and streams. Enforces @Override annotations and specific imports.
Complete collection of Google's official style guides for 17 languages. Includes TypeScript, JavaScript, Python, Java, Go, C++, C#, Swift, Objective-C, HTML/CSS, AngularJS, Shell, R, Common Lisp, Vim Script, JSON, and Markdown. Production-ready coding standards used across Google's engineering organization, formatted for AI agent consumption.
Google's official AngularJS style guide. Covers controllers, services, directives, modules, dependency injection, and AngularJS 1.x best practices.
Google's official Common Lisp style guide. Covers naming conventions, formatting, macros, packages, documentation strings, and Lisp best practices.
Google's official C++ style guide. Covers headers, naming conventions, formatting, classes, memory management, RAII, smart pointers, and modern C++ features.
Google's official C# style guide. Covers naming conventions, formatting, LINQ, async/await, XML documentation, and .NET best practices.
Google's official Go style guide. Covers gofmt formatting, naming conventions, error handling, interfaces, concurrency patterns, and package organization. Enforces idiomatic Go code with short variable names and explicit error checks.
| name | java |
| description | Google's official Java style guide. Covers 2-space indentation, 100-char line limit, naming conventions, braces, imports, Javadoc, exception handling, lambdas, and streams. Enforces @Override annotations and specific imports. |
Official Google Java coding standards for consistent, maintainable code.
@Override whenever applicable| Element | Convention | Example |
|---|---|---|
| Packages | lowercase.dotted | com.example.project |
| Classes/Interfaces | UpperCamelCase | UserService |
| Methods | lowerCamelCase | getUserById |
| Variables | lowerCamelCase | userCount |
| Constants | UPPER_SNAKE_CASE | MAX_RETRIES |
| Type parameters | Single letter | T, RequestT |
// ✓ CORRECT
public class Animal {
private final String name;
public Animal(String name) {
this.name = name;
}
public String speak() {
return name + " makes a sound.";
}
}
// ✓ CORRECT - braces always required
if (condition) {
doSomething();
}
// ✗ INCORRECT - no braces
if (condition)
doSomething();
// ✓ CORRECT - enhanced for loop
for (String item : items) {
process(item);
}
// ✓ CORRECT
try {
processData(input);
} catch (IOException e) {
logger.error("IO error: {}", e.getMessage());
throw new ServiceException("Failed", e);
}
// ✓ CORRECT - try-with-resources
try (InputStream in = new FileInputStream(file)) {
return IOUtils.toByteArray(in);
}
// ✗ INCORRECT
try {
...
} catch (Exception e) { // too broad
e.printStackTrace(); // don't use printStackTrace
}
// ✓ CORRECT
List<String> names = users.stream()
.filter(u -> u.isActive())
.map(User::getName)
.sorted()
.collect(Collectors.toList());
// ✓ CORRECT - method references
users.forEach(System.out::println);
/**
* Finds a user by their unique identifier.
*
* @param userId the user's unique ID
* @return an Optional containing the user, or empty if not found
*/
public Optional<User> findUserById(long userId) { ... }
// ✓ CORRECT
import java.util.List;
import java.util.Optional;
// ✗ INCORRECT
import java.util.*; // no wildcard imports
| Mistake | Correct Approach |
|---|---|
| Wildcard imports | Specific imports only |
| Omitting braces | Always use braces |
| Missing @Override | Always annotate overridden methods |
| e.printStackTrace() | Use a proper logger |
| Catching Exception broadly | Catch specific exceptions |
| 4-space indentation | Use 2-space indentation |
npx skills add testdino-hq/google-styleguides-skills/java
See java.md for complete details, examples, and edge cases.