Posts

Showing posts from February, 2017

How to get Current Location in iOS using Swift?

Image
Get user's current location in iOS Swift To get a user's current location in iOS Swift you need to declare: let locationManager = CLLocationManager() In viewDidLoad() you have to instanitate the CLLocationManager class, like this: // Ask for Authorisation from the User. self.locationManager.requestAlwaysAuthorization() // For use in foreground self.locationManager.requestWhenInUseAuthorization() if CLLocationManager.locationServicesEnabled() {     locationManager.delegate = self     locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters     locationManager.startUpdatingLocation() } Then in CLLocationManagerDelegate method you can get user's current location coordinates: func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {     var locValue:CLLocationCoordinate2D = manager.location.coordinate     print("locations = \(locValue.latitude) \(locValue.longitude)") } In the info.plist you will have to add NSLocation

Enterprise Java Easy Readme to get started in J2EE

Image
J2EE Getting Started Guide Q.What is J2EE ? Answer: server side specifications (APIs)  for different services such as Persistence,web comps(sevlets,JSP,filter)  life -cycle management, EJB(Enterprise Java Bean) management,security,connection pooling,transactions ,JMS(Java Messaging Service), Java mail ,web services support ,JPA(Java persistence API) ,etc. Why ??? 1. Can support different types of clients(thin clnts ---web clnt or Thick clnts --appln clnt, mobile clnts Thin clnt (min)--- only web browser + net conn. to server ---- protocol HTTP/HTTPS Thick clnt (min) --- Java SE support + (optional) server lib + net cn to server protocol --- RMI style protocol.(Server vendor propritery protocol based upon RMI/IIOP) eg -- from core java ---TCP clnt,RMI clnt,UDP clnt 2. Server side applications ---- will be completely independent of underlying web server/application server.(J2EE compliant server) 3. Enterprise applications -- distributed, transactional, and portable applications that leve

Uses of Optional in Java 8

Image
What are the uses of Optional in Java 8? Answer: Java 8 introduced a new  container class java.util.Optional<T> . It wraps a single value, if that value is available. If the value is not available an empty optional should be returned. Thus it represents null value with absent value. This class has various utility methods like isPresent() which helps users to avoid making use of null value checks. So instead of returning the value directly, a wrapper object is returned thus users can avoid the null pointer exception. Class Declaration Following is the declaration for  java.util.Optional<T>  class − public final class Optional<T> extends Object Class Method S. No. Method & Description 1 static <T> Optional<T> empty() Returns an empty Optional instance. 2 boolean equals(Object obj) Indicates whether some other object is "equal to" this Optional. 3 Optional<T> filter(Predicate<? super <T> predicate) If a value is present and the va

Get Interview Ready Java Developers (Freshers)

Image
Important interview Questions for Java Developers 1. If I don't provide any arguments on the command line, then the String array of Main method will be empty or null? Answer: It is empty. But not null. 2. What if I write static public void instead of public static void? Answer:Program compiles and runs properly. 3. What is the default value of the local variables? Answer:The local variables are not initialized to any default value, neither primitives nor object references. 4. How are Observer and Observable used? Objects that subclass the Observable class maintain a list of observers. When an Observable object is updated it invokes the update() method of each of its observers to notify the observers that it has changed state. The Observer interface is implemented by objects that observe Observable objects. 5. What is synchronization and why is it important? With respect to multi-threading, synchronization is the capability to control the access of multiple threads to shared resourc