Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Java EE 8 and Angular

You're reading from   Java EE 8 and Angular A practical guide to building modern single-page applications with Angular and Java EE

Arrow left icon
Product type Paperback
Published in Jan 2018
Publisher Packt
ISBN-13 9781788291200
Length 348 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Prashant Padmanabhan Prashant Padmanabhan
Author Profile Icon Prashant Padmanabhan
Prashant Padmanabhan
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface 1. What's in Java EE 8? FREE CHAPTER 2. The CDI Advantage Combined with JPA 3. Understanding Microservices 4. Building and Deploying Microservices 5. Java EE Becomes JSON Friendly 6. Power Your APIs with JAXRS and CDI 7. Putting It All Together with Payara 8. Basic TypeScript 9. Angular in a Nutshell 10. Angular Forms 11. Building a Real-World Application 12. Connecting Angular to Java EE Microservices 13. Testing Java EE Services 14. Securing the Application 15. Other Books You May Enjoy

Working with arrays

There are multiple ways to work with an array and this works similar to how an array works in JavaScript. You can also declare an array using generics:

let a: number[] = [1,2,3];
let b: Array<number> = [1,2,3];
let c: Array<any> = ['Hello',10];

Here we make use of the for of loop to iterate over the elements in the array, and print each element. Next, we loop again, but using the forEach function:

var numArray = [1, 2, 3];
for (let item of numArray) {
console.log(item); //Produces: 1,2,3
}

//Using forEach to get same output as above
numArray.forEach(element => {
console.log(element);
});

Similar to using a stream() and map() in Java, we can use the map function available to produce a new result which processes each element within the array:

let priorities = ['low', 'medium', 'high'];
let priorityUpperCase = priorities...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime