Tutorialspoint

Java Program to calculate the area of a triangle using Heron's Formula

karthikeya Boyini
Answered 11h 35m ago

Heron’s formula gives the area of a triangle when the length of all three sides are already known.Let’s say we have the following three sides of a triangle −s1 = 15191235.0; s2 = 15191235.0; s3 = 1.01235479;Now, use the Heron’s formulae to find the area −area = (s1+s2+s3)/2.0d; resArea = ... Read More

How to convert Integer array list to integer array in Java?

Samual Sam
Answered 11h 37m ago

To convert integer array list to integer array is not a tedious task. First, create an integer array list and add some elements to it −ArrayList < Integer > arrList = new ArrayList < Integer > (); arrList.add(100); arrList.add(200); arrList.add(300); arrList.add(400); arrList.add(500);Now, assign each value of the integer array list ... Read More

Java Program to get prime numbers using the Sieve of Eratosthenes algorithm

karthikeya Boyini
Answered 11h 41m ago

To find all prime numbers up to any given limit, use the Sieve of Eratosthenes algorithm. At first we have set the value to be checked −int val = 30;Now, we have taken a boolean array with a length one more than the val −boolean[] isprime = new boolean[val + ... Read More

Java Program to create a Calculator

Samual Sam
Answered 11h 46m ago

To create a calculator with Java Swings, try the following code −Exampleimport java.awt.Color; import java.awt.Container; import java.awt.FlowLayout; import javax.swing.JFrame; import javax.swing.JLabel; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JTextField; public class SwingDemo extends JFrame implements ActionListener {    JButton one, two, three, four, five, six, seven, eight, nine, num0, ... Read More

Java Program to save decimal

karthikeya Boyini
Answered 11h 50m ago

Let’s say the value is 0.10705921712947473 and you want to save only the first 3 decimal digits. At first let us declare the values −double val = 320.0 / 2989.0; BigDecimal big = new BigDecimal(val);Now, use setScale() and set the parameter as 3 to save 3 decimal places −big = ... Read More

Java Program to evaluate mathematical expressions in String

Samual Sam
Answered 11h 52m ago

To evaluate mathematical expression in String, use Nashorn JavaScript in Java i.e. scripting. Nashorn invoke dynamics feature, introduced in Java 7 to improve performance.For scripting, use the ScriptEngineManager class for the engine −ScriptEngineManager scriptEngineManager = new ScriptEngineManager(); ScriptEngine scriptEngine = scriptEngineManager.getEngineByName("JavaScript");Now for JavaScript code from string, use eval i.e. execute ... Read More

How to integrate a facebook login in swift for iOS App?

Fendadis John
Answered on 18th Apr, 2019

Social logins in applications have become a very common thing these days. Facebook login is one of them, in this article we’ll see how we can make use of facebook login, to access basic user information and login to the application.Implementing facebook login in an application is a series of ... Read More

How do you hide the onscreen keyboard in iOS App?

Rama Giri
Answered on 18th Apr, 2019

To hide a keyboard on screen we need to make use of some internal functions that are predefined in the iOS SDK. The keyboard appears on screen when we are typing in a text Field or textView. We need to make use of internal function according to the text field.For ... Read More

How to resize an UIImageView using Swift?

Rama Giri
Answered on 18th Apr, 2019

To resize an image in iOS using swift we’ll make use of frame.Let’s see this with help of an example.Create an empty project and add an empty Image view.Create its outlet.Add an image to your project and assign the image to image view.Initially when we run the application, it looks ... Read More

How do I load an image by URL on iOS device using Swift?

Fendadis John
Answered on 18th Apr, 2019

To load an image in iOS using swift we’ll make use of simple data Task session. The image needs to be loaded in background because it may be of any size and we don’t want it to stop our main view’s operations.Let’s see this with help of an example. Create ... Read More

How to make an HTTP POST request on iOS App using Swift?

Rama Giri
Answered on 18th Apr, 2019

To make an http request in iOS we’ll make use of DataTask and sessions. We’ll create configuration, sessions, url, request, and dataTask objects. Let’s see the steps that we’ll go through.First of all we need to create a session object, which default configuration.let configuration = URLSessionConfiguration.default let session = URLSession(configuration: ... Read More

How to check Location Manager is running or not in iOS App?

Fendadis John
Answered on 18th Apr, 2019

To check any services related to location in ios with swift we can use the CLLocationManager.In this example we’ll see how to check if the location manager is running or not. We’ll do this with help of an sample project. So, create a new project. First we need to create ... Read More

Getting a distinct aggregation of an array field across indexes

Ankith Reddy
Answered on 11th Apr, 2019

To get a distinct aggregation of an array field across indexes, let us take an example and create a collection with some documents.Following is the query to create a collection with documents> db.distinctAggregation.insertOne({"UserName":"Larry", "UserPost":["Hi", "Hello"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c98aefb330fd0aa0d2fe4c6") } > db.distinctAggregation.insertOne({"UserName":"Chris", "UserPost":["Hi", "Good Morning"]}); ... Read More

How to use “OR” condition in MySQL CASE expression?

George John
Answered on 17th Apr, 2019

Set the same condition like “OR” in a MySQL CASE expression. Let us first create a sample table.Following is the querymysql> create table caseOrConditionDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Name varchar(100),    -> Score int    -> ); Query OK, 0 ... Read More

How to make an HTTP request on iOS App using Swift?

Fendadis John
Answered on 17th Apr, 2019

To make an http request in iOS we’ll make use of DataTask and sessions. We’ll create configuration, sessions, url, request, and dataTask objects. Let’s see the steps that we’ll go through.The HTTP request can be of different types, it depends on what kind of request we want to make to ... Read More

Advertisements
Loading...
Unanswered Questions View All

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.