IntelliJ IDEA सेटअप करना
In this page:
Why IntelliJ IDEA?
IntelliJ IDEA, JetBrains का अपना IDE है, और चूंकि JetBrains ने Kotlin भी बनाई, IntelliJ सबसे पूरा Kotlin support देता है: instant error checking, auto-completion, refactoring tools, और एक integrated debugger।
उदाहरण: Why IntelliJ IDEA?
// Entry point: execution of the program starts here
fun main() {
// Print "IntelliJ IDEA gives instant feedback while you type Kotlin" to the console, with a trailing newline
println("IntelliJ IDEA gives instant feedback while you type Kotlin")
}
Login to try C/C++/Java/PHP code in the editor
Creating a New Kotlin Project
Welcome screen से, New Project -> Kotlin चुनना आपको एक build system (Gradle या IntelliJ) और एक JDK चुनने देता है। एक minimal Kotlin/JVM console project को code चलाना शुरू करने के लिए बस इतना ही चाहिए।
उदाहरण: Creating a New Kotlin Project
// Entry point: execution of the program starts here
fun main() {
// Print "A new Kotlin project created in IntelliJ IDEA" to the console, with a trailing newline
println("A new Kotlin project created in IntelliJ IDEA")
}
Login to try C/C++/Java/PHP code in the editor
Running Code with the Green Arrow
IntelliJ किसी भी fun main() function के बगल में एक छोटा green triangle दिखाता है; उस पर click करना उस file को तुरंत compile और run करता है, window के नीचे Run panel में output दिखाते हुए।
उदाहरण: Running Code with the Green Arrow
// Entry point: execution of the program starts here
fun main() {
// Print "Click the green run arrow next to main() to execute this" to the console, with a trailing newline
println("Click the green run arrow next to main() to execute this")
}
Login to try C/C++/Java/PHP code in the editor
Using Code Inspections
IntelliJ type करते समय problematic code को लाल (errors) या पीले (warnings/suggestions) में underline करता है, और Alt+Enter इनमें से कई के लिए quick-fixes खोलता है, जैसे कोई missing import जोड़ना या किसी expression को सरल बनाना।
उदाहरण: Using Code Inspections
// Entry point: execution of the program starts here
fun main() {
// Declare a read-only variable `message`, set to `"IntelliJ suggests fixes with Alt+Enter"`
val message = "IntelliJ suggests fixes with Alt+Enter"
// Print `message` to the console, with a trailing newline
println(message)
}
Login to try C/C++/Java/PHP code in the editor
- यह मान लेना कि किसी Kotlin project को हमेशा IntelliJ के अंदर एक Android project के रूप में बनाना चाहिए, जबकि एक plain Kotlin/JVM project ठीक काम करता है।
- project बनाते समय JDK चुनना भूल जाना, जिससे IDE को compile करने के लिए कोई runtime नहीं मिलता।
- IDE के दिखाए लाल/पीले underlines को नज़रअंदाज़ करना और पहले flagged issue ठीक करने के बजाय code को वैसे ही चलाना।
- IntelliJ IDEA JetBrains ने बनाया है, वही company जिसने Kotlin बनाई, इसलिए इसका Kotlin support first-class है।
- मुफ़्त Community Edition plain Kotlin/JVM projects के लिए काफी है; Android और web projects को Ultimate से फायदा होता है।
- नया project बनाना आपसे एक JDK और एक build system (Gradle, Maven, या IntelliJ का अपना builder) चुनने को कहता है।
- IntelliJ का built-in Run button एक click में आपका
main()function compile और execute करता है।
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: