长注释在JAVA中

huangapple go评论77阅读模式
英文:

Long Comments in JAVA

问题

请问我可以使用像这样带有长破折号的注释来分隔我的代码吗?

这会影响我的应用程序性能或任何其他方面吗?我在考虑在所有的活动中都这样做。

   radioSection.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(RadioGroup group1, int checkedId1) {
              switch (checkedId1) {
                  case R.id.rbSr:
                      section = "SR";
                      break;
                  case R.id.rbJr:
                      section = "JR";
                      break;
              }
          }
      });
//----------------------------------------------------------------//----------------------------------------------------------------
        db = FirebaseFirestore.getInstance();
        firebaseAuth = FirebaseAuth.getInstance();
//----------------------------------------------------------------//----------------------------------------------------------------
   next.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
             String name1 = FullName.getText().toString().trim();
             String name2 = DOB.getText().toString().trim();

            if(radioGender.getCheckedRadioButtonId() == -1 || radioSection.getCheckedRadioButtonId() == -1 || name1.isEmpty() || name2.isEmpty() || subsection.equals("Select Sub-Section") || subject.equals("Select Subject")){
                 Toast.makeText(ADDdetails.this, "Enter Details", Toast.LENGTH_SHORT).show();
             }else{
                 updateUserDetails();
             }
         }
     });
//----------------------------------------------------------------//----------------------------------------------------------------
英文:

Is it ok if I use Comments with long dashes like this to seperate my code?

Will it affect the performance of my application or any other aspect?I was thinking to do this in all of my activities.

   radioSection.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(RadioGroup group1, int checkedId1) {
              switch (checkedId1) {
                  case R.id.rbSr:
                      section = "SR";
                      break;
                  case R.id.rbJr:
                      section = "JR";
                      break;
              }
          }
      });
//----------------------------------------------------------------//----------------------------------------------------------------
        db = FirebaseFirestore.getInstance();
        firebaseAuth = FirebaseAuth.getInstance();
//----------------------------------------------------------------//----------------------------------------------------------------
   next.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
             String name1 = FullName.getText().toString().trim();
             String name2 = DOB.getText().toString().trim();

            if(radioGender.getCheckedRadioButtonId() == -1 || radioSection.getCheckedRadioButtonId() == -1 || name1.isEmpty() || name2.isEmpty() || subsection.equals("Select Sub-Section") || subject.equals("Select Subject")){
                 Toast.makeText(ADDdetails.this, "Enter Details", Toast.LENGTH_SHORT).show();
             }else{
                 updateUserDetails();
             }
         }
     });
//----------------------------------------------------------------//----------------------------------------------------------------

答案1

得分: 4

根据定义,注释不影响程序的执行。

来自Oracle的这个教程
> 编译器会忽略注释,但对其他程序员很有用。

从风格的角度来看是否可以接受是一个观点问题。

英文:

By definition, comments don't affect execution of the program.

From this tutorial from Oracle,
> Comments are ignored by the compiler but are useful to other programmers.

Whether it's OK or not from a stylistic perspective is a matter of opinion.

答案2

得分: 0

从您个人使用的角度来看,这没问题。注释代码块将被忽略。在团队环境中进行注释时,与团队期望保持一致是很重要的。

英文:

For your own personal use perspective it'll be fine. The blocks of commented code will be ignored. When it comes to commenting in a team environment it's important to be uniform with what the team wants.

答案3

得分: -1

不会影响应用程序,但会影响编译器,因为它必须从代码中提取注释。

英文:

It will not affect application, but it will affect compiler because it has to extract comments from code.

huangapple
  • 本文由 发表于 2020年9月25日 21:12:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/64064874.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定