Java 中的分隔符

原文:https://www.geeksforgeeks.org/separators-in-java/

不管是不是一个程序员,他不知道这个概念,但却沉迷于每一个程序。分隔符帮助我们定义程序的结构。在 Java 中,用作分隔符的字符很少。java 中最常用的分隔符是分号(;).让我们借助“你好世界”计划的插图进行更多探索,以更加强调分隔符。

插图:hello world

Java

// Java Program to Illustrate Separators in Java

// Main class
class GFG {

    // Main driver method
    public static void main(String[] args)
    {

        // Print statement
        System.out.println("Hello World");
    }
}

观察结果如下:

  • In line 3, ' {' is used to define the block class GFG.
  • At the beginning of line 6, ' {' is used to define the block main method.
  • In the 10th line, [T0】' 【T1] is used to terminate the sentence.
  • In the 11th line, "}" is used to define the end of the block method.
  • In the 12th line, "}" is used to define the block class GFG.

的结尾

这些分隔符图示如下:

[ | symbol | name | Purpose | | --- | --- | --- | | ) | Brackets | are used to contain the list of parameters in method definition and call. It is also used to define the priority of the expression in the control statement and the type of the surrounding cast | | {} | Braces | are used to define the code block. Classes, methods and local ranges are used to contain the values | | [] | brackets | that automatically initialize the array, and are used when dereferencing the array values | | ; | Semicolon | Termination statement | | | Comma | is used to separate the package name from the sub-package name and class name, and you can also select the field or method | | Period | The continuous identifier in the declaration of separated variables is also used in the chain statement under test, and an expression for loop | | : | Colon | is used in the tag | |

之后

本文由 Swati Jha 供稿。如果你喜欢极客博客并想投稿,你也可以用 write.geeksforgeeks.org 写一篇文章或者把你的文章邮寄到 review-team@geeksforgeeks.org。看到你的文章出现在极客博客主页上,帮助其他极客。

如果你发现任何不正确的地方,或者你想分享更多关于上面讨论的话题的信息,请写评论。