Output Fixed Number of Array Elements in a Line in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

197 Views

To output fixed number of array elements in a line, we should check for a condition and if that is true, we should place System.out.println(); properly to get a line and the process goes on.Here, we will display 5 elements in a line. At first, create a new integer array and add some elements −int[] list = new int[50]; for (int i = 0; i < list.length; i++) {    list[i] = (int)(i + 20); }Now, declare a new variable and initialize it to 0. This variable is checked in a for loop that loops until the length of the ... Read More

Ternary Operation in MySQL Compared to C and C++

Samual Sam
Updated on 30-Jul-2019 22:30:25

114 Views

Yes, let us first see the working of ternary operator in C or C++ language.X=(X > 10 && ( X-Y) < 0) ?: X:(X-Y);Here is the demo code in C language. After that we will check in MySQL. The C code is as follows −#include int main() {    int X;    int Y;    int result;    printf("Enter the value for X:");    scanf("%d", &X);    printf("Enter the value for Y:");    scanf("%d", &Y);    result=( X > 1 && (X-Y) < 0) ? X: (X-Y);    printf("The Result is=%d", result);    return 0; }The snapshot of C ... Read More

Multiplexer and Demultiplexer in 8085 Microprocessor

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

6K+ Views

Let us consider the instruction to be executed as “MOV A, C”. Here in this case the value of 8 bit in the register C must be moved to the register. The given set of registers namely B, C, D, E, H, and L must be connected to the internal bus by means of a multiplexer (many input but only one output) or demultiplexer the reverse of multiplexer. The register meant to carry the work selects the specific unit and sends the appropriate code to the multiplexer such that the contents of register C are sent out to the multiplexer ... Read More

Use Bubble Chart Graph in Android

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

575 Views

This example demonstrate about How to use Bubble chart graph in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Open build.gradle(module level) and add library dependency.apply plugin: 'com.android.application' android {    packagingOptions {       exclude 'META-INF/proguard/androidx-annotations.pro'    }    packagingOptions {       exclude 'META-INF/DEPENDENCIES'       exclude 'META-INF/LICENSE'       exclude 'META-INF/LICENSE.txt'       exclude 'META-INF/license.txt'       exclude 'META-INF/NOTICE'       exclude 'META-INF/NOTICE.txt'       exclude 'META-INF/notice.txt'     ... Read More

Insert New Documents into a MongoDB Collection

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

304 Views

To insert new documents into a MongoDB collection, you need to use insert() method or save() method.Case 1: Using insert() method.The syntax is as follows:db.yourCollectionName.insert(yourDocument);Case 2: Using save() method.The syntax is as follows:db.yourCollectionName.save(yourDocument);In the above syntax, if your collection name does not exist then MongoDB will create a new collection and insert the document in the collection.The query to insert new documents is as follows for both the cases discussed above.Case 1: Using insert() method. The query is as follows:> db.userInformation.insert({    ... "Name":"John",    ... Age:30,    ... isStudent:false,    ... "Subjects":["Introduction to java", "Introduction to MongoDB"]    ... ... Read More

Create a New User with Password in MySQL 8

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

3K+ Views

You need to use CREATE command to create a new user with password in MySQL 8. Let us check the versionmysql> select version(); +-----------+ | version() | +-----------+ | 8.0.12    | +-----------+ 1 row in set (0.14 sec)The syntax is as follows to create a new user with passwordCREATE USER 'yourUserName'@'localhost' IDENTIFIED BY 'yourPassword';The following is the syntax to grant all privileges to the created userGRANT ALL ON *.* TO 'yourUserName'@'localhost';Now flush the privileges using flush commandflush privileges; Let us create a new user with the help of the above syntax. The query is as followsmysql> use MySQL; Database ... Read More

JSTL Formatting Tags in JSP

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

587 Views

The JSTL formatting tags are used to format and display text, the date, the time, and numbers for internationalized Websites. Following is the syntax to include Formatting library in your JSP −Following table lists out the Formatting JSTL Tags −S.No.Tag & Description1: To render numerical value with specific precision or format.2: Parses the string representation of a number, currency, or percentage.3: Formats a date and/or time using the supplied styles and pattern.4: Parses the string representation of a date and/or time5: Loads a resource bundle to be used by its tag body.6: Stores the given locale in the locale configuration variable.7: Loads a resource bundle and ... Read More

LocalDate withDayOfMonth Method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

155 Views

An immutable copy of a LocalDate with the day of month altered as required is done using the method withDayOfMonth() in the LocalDate class in Java. This method requires a single parameter i.e. the day of month that is to be set in the LocalDate and it returns the LocalDate with the day of month altered as required.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main {    public static void main(String[] args) {       LocalDate ld1 = LocalDate.parse("2019-02-15");       System.out.println("The LocalDate is: " + ld1);     ... Read More

Create Octet Tuple from Another Collection in Java

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25

134 Views

You can create Octel Tuple from another collection i.e. List or arrays. For List, use the fromCollection() method.Let us first see what we need to work with JavaTuples. To work with Octet class in JavaTuples, you need to import the following package −import org.javatuples.Octet;Note: Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java Build Path -> Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples −Steps: How to run JavaTuples program in EclipseThe following is an ... Read More

Replace Substring with Another Substring in C++

Nitya Raut
Updated on 30-Jul-2019 22:30:25

2K+ Views

Here we will see how to replace substring with another substring. It replaces the portion of the string that begins at character pos and spans len characters.The structure of the replace function is like below:string& replace (size_t pos,  size_t len,  const string& str,  size_t subpos,  size_t sublen);The parameters are pos: It is an insertion point, str : It is a string object, len : It contains information about number of characters to erase.AlgorithmStep 1: Get the main string, and the string which will be replaced. And the match string Step 2: While the match string is present in the main string: Step 2.1: Replace it with the given ... Read More

Advertisements