Arrays vs Collections

Image Posted on Updated on

colArr

Advertisements

Web Application/Enterprise Application

Posted on

  • Web application can be developed only by web related technologies like html, jsp’s ,servelets etc. Ex:Online Shopping App etc
  • Enterprise application can be developed using anything from java J2EE,hence enterprise application is a superior application. Ex:Banking,Telecom projects etc.

 

Web Server vs Application Server

Posted on

  • Web Server: Provides environment to run Web applications.
  • Application Server:->Provides environment to run Enterprise applications.

    –>Every Application server has an inbuilt web server.

 

 

 

Jar vs War vs Ear

Posted on Updated on

  • jar: Java archieve file- It is a group of .class files.
  • war: Web archieve file-It represents a web application in single zip file .(all the jsp,html,servelets etc).
  • ear: Enterprise archieve file-It represents a enterpriseapplication in single zip file .(all the jsp,EJB’s,jms,servelets etc).

Difference between Streams and Collections in Java

Posted on Updated on

Main differences between Collection and Stream API in Java 8 are:

I. Version: Collection API is in use since Java 1.2. Stream API is recent addition to Java in version 8.

II. Usage: Collection API is used for storing data in different kinds of data structures. Stream API is used for computation of data on a large set of Objects.

III. Finite: With Collection API we can store a finite number of elements in a data structure. With Stream API, we can handle streams of data that can contain infinite number of elements.

IV. Eager vs. Lazy: Collection API constructs objects in an eager manner. Stream API creates objects in a lazy manner.

V. Multiple consumption: Most of the Collection APIs support iteration and consumption of elements multiple times. With Stream API we can consume or iterate elements only once.

 

With a stream you can basically treat collections as you would in a functional language. For example you can map and filter on them. The idea is that the java developers didn’t add this functionality to collections before so they added streams.

As an example say you had a list of integers and you wanted to select those which are below 10. Without streams you would do something like this

List<Integer> listBelowTen = new ArrayList<Integer>

for (Int i : listOfInts) {

if (i < 10) {

listBelowTen.add(i);

}

}

This is a lot of lines of code to do a relatively simple thing.

With streams you simply do this:

List<Integer> listBelowTen = listOfInts.stream().filter(i -> i< 10).collect(AsList ());

So it basically adds a lot more functionality to your collections.

JavaScript: parseInt() Function

Posted on Updated on

  • The parseInt() function parses a string and returns an integer.

Syntax: parseInt(string, radix)

String is required and radix is optional.

  • The radix parameter is used to specify which numeral system to be used, for example, a radix of 16 (hexadecimal) indicates that the number in the string should be parsed from a hexadecimal number to a decimal number.If the radix parameter is omitted, JavaScript assumes the following:
    • If the string begins with “0x”, the radix is 16 (hexadecimal)
    • If the string begins with “0”, the radix is 8 (octal). This feature is deprecated
    • If the string begins with any other value, the radix is 10 (decimal)
    • Only the first number in the string is returned!
    • Leading and trailing spaces are allowed.
    • If the first character cannot be converted to a number, parseInt() returns NaN.

     

Example:

var a = parseInt(“10”) + “<br>”;—-10
var b = parseInt(“10.00”) + “<br>”;—-10
var c = parseInt(“10.33”) + “<br>”;—-10
var d = parseInt(“34 45 66”) + “<br>”;—34
var e = parseInt(” 60 “) + “<br>”;—–60
var f = parseInt(“40 years”) + “<br>”;—-40
var g = parseInt(“He was 40”) + “<br>”;—NaN

var h = parseInt(“10”, 10)+ “<br>”;—-10
var i = parseInt(“010”)+ “<br>”;—–10
var j = parseInt(“10”, 8)+ “<br>”;—-8
var k = parseInt(“0x10”)+ “<br>”;—-16
var l = parseInt(“10”, 16)+ “<br>”;—–16