Explore Courses Blog Tutorials Interview Questions
0 votes
in Java by (13.1k points)

Can anyone help me how I can able to create an array without using any bracket notation. But it is giving an error:

var myNewArray = [a: 200, b: 300]; // I am getting error - Unexpected token:

Any help would be appreciated.

1 Answer

0 votes
by (26.7k points)

In able to do that, you can use the below format which will help you achieve what you want:

var myObj = {a: 200, b: 300};

It will help you to map strings to the values.

I hope this will help.

Want to become a Java Expert? Join Java Certification now!!

Want to know more about Java? Watch this video on Java Tutorial for Beginners | Java Tutorial:

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Mar 17, 2021 in Java by dante07 (13.1k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.5k questions

32.5k answers


108k users

Browse Categories