Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8502289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:26:36+00:00 2026-06-11T01:26:36+00:00

While learning Java’s basics, I remember coming across a particular syntax for passing arguments

  • 0

While learning Java’s basics, I remember coming across a particular syntax for passing arguments to a class constructor. I found this syntax extra read-able, but I’m sadly not able to find it anymore. It looked somewhat like the following:

// Creating an instance of the Employee class (has property name, salary, etc)
Employee fred = new Employee({
    name: "Fred",
    salary: 5000
    job: Jobs.PROGRAMMER
});

As you probably can see, it becomes very clear what each argument to the constructor means, which eliminates the need to look at documentation – just to understand simple code.

Am I mixing languages up or does a syntax somewhat like this exists? An eventual link to the manual would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T01:26:37+00:00Added an answer on June 11, 2026 at 1:26 am

    This is not Java syntax (and never was).

    What you can do is to achieve something similar is to use Anonymous classes with initializers like this

    class Employee{
        String first;
        String last;
    }
    
    Employee mike = new Employee(){{
        first = "Mike";
        last  = "Meyers";
    }};
    

    There is an explanation of what is going on here: http://blog.schauderhaft.de/2012/08/19/named-parameters-in-java-another-alternative/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While learning Java I have come across a lot of questions regarding how to
I'm learning Java and find myself sending methods around while asking for help but
While learning Rails, I found this example in the Sam Ruby's book: app/controllers/line_items_controller.rb def
So I found some similarities between arrays and set notation while learning about sets
I'm a Java Developer wich is learning VB.net for a small project. While coding
I am learning java multi-threading, I found it's hard to understand how synchronized block
This is a real beginner question (I'm still learning the Java basics). I can
While learning about java memory profiling, I keep seeing the term perm space in
Its quite a while since I started learning Java EE (I come from Rails
While learning Java I stumble upon this error quite often. It goes like this:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.