Fill Elements in a Java Char Array in a Specified Range

Ankith Reddy
Updated on 30-Jul-2019 22:30:24

263 Views

Elements can be filled in a Java char array in a specified range using the java.util.Arrays.fill() method. This method assigns the required char value in the specified range to the char array in Java.The parameters required for the Arrays.fill() method are the array name, the index of the first element to be filled(inclusive), the index of the last element to be filled(exclusive) and the value that is to be stored in the array elements.A program that demonstrates this is given as followsExample Live Demoimport java.util.Arrays; public class Demo { public static void main(String[] argv) throws Exception { ... Read More

Locale Specific Formatting in Java

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

158 Views

For locale-specific formatting, firstly import the following packages.import java.util.Calendar; import java.util.Formatter; import java.util.Locale;Create a Formatter and Calendar object −Formatter f = new Formatter(); Calendar c = Calendar.getInstance();We are formatting for different Locales −f.format(Locale.TAIWAN, "Locale.TAIWAN: %tc", c); f.format(Locale.ITALY, "Locale.ITALY: %tc", c);The following is an example −Example Live Demoimport java.util.Calendar; import java.util.Formatter; import java.util.Locale; public class Demo { public static void main(String args[]) { Formatter f = new Formatter(); Calendar c = Calendar.getInstance(); f.format(Locale.TAIWAN, "Locale.TAIWAN: %tc", c); ... Read More

Insert Data to MySQL with Auto-Incremented Primary Key

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

3K+ Views

Whenever your column has an auto incremented primary key then there is an advantage that you do not need to give value for that column in the INSERT command. This means MySQL will give the value for that column.To understand the above concept, let us first create a table. The query to create a table is as follows −mysql> create table AutoIncrementedPrimary    -> (    -> Id int auto_increment,    -> Name varchar(100),    -> Age int,    -> Primary key(Id)    -> ); Query OK, 0 rows affected (0.56 sec)Now insert records for the column Name and Age ... Read More

Find Maximum and Minimum of 10 Numbers in 8085

Rishi Rathor
Updated on 30-Jul-2019 22:30:24

2K+ Views

In this program we will see how to find the maximum and minimum number in a block data.Problem StatementWrite 8085 Assembly language program to find the maximum and minimum number in a block often 8-bit numbers.DiscussionIn this program we are taking the first number of the block into register D and E. The D will store the minimum number, and E will store maximum number. In each iteration we will check whether the number is smaller than D or not, if it is smaller, then update D with the new number, and then compare it again with E to check ... Read More

MySQL Query to Group User Login Time Per Hour

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

319 Views

You can use a subquery with JOIN condition for this. The syntax is as follows −SELECT yourTablevariableName.* FROM ( SELECT MAX(UNIX_TIMESTAMP(yourDateTimeColumnName)) AS anyAliasName FROM getLatestHour GROUP BY HOUR(UserLoginDateTime) ) yourOuterVariableName JOIN yourTableName yourTablevariableName ON UNIX_TIMESTAMP(yourDateTimeColumnName) = yourOuterVariableName.yourAliasName WHERE DATE(yourDateTimeColumnName) = 'yourDateValue';To understand the above syntax and the result to be achieved, let us create a table. The query to create a table is as follows −mysql> create table getLatestHour -> ( -> UserId int, -> UserName varchar(20), -> UserLoginDateTime ... Read More

Format Output with Formatter in Java

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

343 Views

For Formatter, import the following package −import java.util.Formatter;Now create a Formatter object −Formatter f1 = new Formatter();Now, we will format the output with Formatter −f1.format("Rank and Percentage of %s = %d %f", "John", 2, 98.5);The following is an example −Example Live Demoimport java.util.Formatter; public class Demo { public static void main(String args[]) { Formatter f1 = new Formatter(); Formatter f2 = new Formatter(); f1.format("Rank and Percentage of %s = %d %f", "John", 2, 98.5); ... Read More

MySQL Error: Data Too Long for Column

Rishi Rathor
Updated on 30-Jul-2019 22:30:24

21K+ Views

The “Data too long for column” error occurs when you insert more data for a column that does not have the capability to store that data.For Example - If you have data type of varchar(6) that means it stores only 6 characters. Therefore, if you will give more than 6 characters, then it will give an error.Let us create a table to understand the error. The query to create a table is as follows −mysql> create table DataToolongDemo   −> (   −> Name varchar(10) −> ); Query OK, 0 rows affected (0.55 sec)Above, we have created a table ... Read More

First Person on Earth According to Hindu Mythology

Knowledge base
Updated on 30-Jul-2019 22:30:24

20K+ Views

According to Matsyapurana, the first person on this Earth is Manu. The Sanskrit term Maanav meaning a human was derived from the name Manu denoting his children. Manu was the son of Prajapati (another name of Brahma) and Shatrupa (another name of Saraswati). God created Ananti as the wife of Manu. These two are said to be the parents of this world according to Hindu Mythology.Manu and ManvantaraManu is considered the author of ancient Sanskrit code of law called Manu Smriti. Manu is the head of each Kalpa (Aeon), which consists of fourteen Manvantaraas. Each Manvantara lasts for the lifetime ... Read More

Set Target and Action for UIBarButtonItem at Runtime

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

1K+ Views

To create a bar button action at run time we’ll need to go through a few steps. First of all let’s start by creating a new project.Once you have created the project, go to it’s storyboard directly, select the ViewController and Embed it into a navigation controller.Now go to the respective View controller class and inside it, we’ll perform some steps that will add a button to the navigation bar on run time.Create an objc function that should be called when the button is pressed.@objc func barButtonAction() {    print("Button pressed") }Now add the viewWillLayoutSubviews method to your class.First, we’ll ... Read More

Find Larger of Two 8-Bit Numbers in 8085

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

4K+ Views

In this program we will see how to find the larger of two numbers.Problem StatementWrite 8085 Assembly language program to find the larger number of two 8-bit number store dat location 8000H and 8001H.DiscussionThis checking is done by using the CMP instruction. This instruction is very similar to the SUB instruction. The only difference is that it does not update the value of Accumulator after executing. So after comparing, if the CY flag is set, it means that the first number is smaller, and the second one is largerInputFirst inputAddressData......8000FD800123......second inputAddressData......800059800175......Flow DiagramProgramAddressHEX CodesLabelMnemonicsCommentsF00021, 00, 80LXI H, 8000HPoint to the first ... Read More

Advertisements