IntelliJ IDEA – the IDE for Professional Development in Java and Kotlin
Créer du code de qualité requiert de suivre certaines règles. Dans cet article, nous partageons plusieurs bonnes pratiques, conseils et astuces incontournables, qui s'appliquent au développement logiciel en général et aux spécificités des projets Java. C'est parti ! Conseils d'ordre général Il est i…
In March 2014, the Ice Bucket Challenge helped the internet come together to fight ALS. Disney’s Frozen taught a generation of children to Let It Go, and the community saw the release of Java 8 LTS to much fanfare. In fact, as per the JetBrains Developer Ecosystem survey, Java 8 still holds the top …
Previously, we explored how to throw exceptions in Java to signal error conditions in our code. But throwing exceptions is only half the story. To build robust and reliable applications, we also need to know how to handle them effectively. In this post, we’ll explore how you can handle exceptions…
Java 中的异常用于指示程序执行期间发生并扰乱正常指令流的事件。 发生异常时,Java 运行时会自动停止当前方法的执行, 将带有错误信息的异常对象传递到可以处理异常的最近的 catch 块。 虽然妥善捕获和处理异常很重要,但了解如何有效抛出异常也同样重要。 在这篇博文中,我们将探讨引发 Java 异常的细节,涵盖不同类型的异常、如何创建自定义异常等。 如何抛出异常 要让 Java 运行时知道代码中发生了异常,首先必须抛出一个异常。 在 Java 中,您可以使用 throw 关键字调用 Java 虚拟机 (JVM) 中的异常机制: throw new Exception("Something …
在 Java 和其他编程语言中,继承是面向对象编程的基本特性之一。 借助继承,您可以创建从类(基类或超类)派生的类,并重用、扩展或修改超类的行为。 这一原则允许您构建类层次结构和重用现有代码。 Java 本身到处都使用继承:许多 JDK 类继承其他类,并且 Java 中的每个类都隐式扩展 java.lang.Object。 本文不会过多关注这一部分,而主要举例说明如何在代码中使用继承。 假设,您想要在应用程序中创建 Employee 和 Customer 类。 借助继承,您可以编写这两个类,使其从父 Person 类继承 name 和 address 属性。 在代码可重用性和模块化方面,这有多…
好的代码都会遵循一定规则,了解这些规则将增大您成功的几率。 我们将在本文中分享一些 Java 最佳做法,为您提供帮助。 我们将介绍必知提示和技巧,涵盖软件开发的总体建议以及 Java 和项目特定的专业知识。 我们开始吧! 常规 首先,牢记以下有关现代编码的一般规则。 干净好过聪明 代码的主要目的是被理解和维护,而不是炫耀技术能力。 干净的代码会让软件更易于调试、维护和扩展,使参与项目的所有人受益。 复杂并不是荣誉奖章,简单和可读才是。 考虑以下示例。 聪明的: 这是交换变量 `a` 和 `b` 值的非常规方式。 虽然聪明,但乍一看可能会令人困惑。 干净的: 这是更常见的方式。…
Exceptions in Java are used to indicate that an event occurred during the execution of a program and disrupted the normal flow of instructions. When an exception occurs, the Java runtime automatically stops the execution of the current method. It passes an exception object with information about the…
Good code follows certain rules, and knowing them increases your chances of success. We’d like to share some Java best practices that will help you on your way. We'll cover the must-know tips and tricks, from broad advice on software development to Java- and project-specific know-how. Let's get star…
Polymorphism is the ability of an object to take on different forms. In programming, this means that a variable or a method can have different behaviors depending on the type of object it represents. While the term may sound intimidating to beginners, polymorphism is a powerful tool: it helps you re…
Inheritance is one of the fundamental attributes of object-oriented programming, in Java and other programming languages. It lets you create classes that are derived from another class (base class or superclass) and reuse, extend, or modify the behavior of the superclass. This principle allows you t…
Starting with Java can feel overwhelming – there are so many options and so little time. That's where this article comes in handy – consider it your roadmap to learning Java with ease. Whether you're just starting out or have watched every Java tutorial in existence but still feel stuck, we’ve compi…
In this blog, we’re going to take a look at the Feature Trainer in IntelliJ IDEA. New and existing users to IntelliJ IDEA can use this to get more familiar with the shortcuts, features and workflows that the IDE has to offer. You can watch the associated screencast here if you prefer. We integrated…