Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: What to call this? 9.31

  1. #1
    Junior Member
    Join Date
    Aug 2017
    Posts
    23
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Question What to call this? 9.31

    Can someone tell me what is the purpose of the block in the middle of the main method ? what do you call such action ?



    public class test {
      private static int i = 0;
      private static int j = 0;
      public static void main(String[] args) {
        int i = 2;
        int k = 3;
        {
          int j = 3;
          System.out.println("i + j is " + i + j);
        }
        k = i + j;
        System.out.println("k is " + k);
        System.out.println("j is " + j);
      }
    }

    like i can tell by running the code but what is its purpose and what do you call it.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: What to call this? 9.31

    I think it is called a block: https://docs.oracle.com/javase/tutor...pressions.html
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Is there an API to call the .rpt file
    By sparks in forum Java SE APIs
    Replies: 2
    Last Post: January 9th, 2018, 08:32 PM
  2. What is wrong with the call?
    By gtrankle in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 24th, 2013, 01:45 PM
  3. call by value and call by reference
    By Appu14 in forum The Cafe
    Replies: 1
    Last Post: September 2nd, 2012, 06:58 AM
  4. How to call database???
    By mahoppe in forum JDBC & Databases
    Replies: 2
    Last Post: August 23rd, 2011, 08:31 PM
  5. Call by Reference & Call by Value
    By Lokesh in forum Java Theory & Questions
    Replies: 1
    Last Post: February 21st, 2011, 01:19 PM