Using Varargs with Standard Arguments in Java

Vikyath Ram
Updated on 30-Jul-2019 22:30:24

200 Views

A method with variable length arguments(Varargs) in Java can have zero or multiple arguments. Variable length arguments(Varargs) can also be used with standard arguments However they must be the last argument in the argument list. Moreover, there can only be one variable length argument in the method.A program that demonstrates this is given as follows:Example Live Demopublic class Demo {    public static void Varargs(int i, String... str) {       System.out.println("Number of Vararg are: " + i);       System.out.println("The argument values are: ");       for (String s : str)          System.out.println(s);   ... Read More

Garbage Collection in Python

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

1K+ Views

Python memory management is straight forward. You don’t need to worry about memory management, as memory allocation and deallocation is automatic. one of the mechanisms of memory management is garbage collection. Let’s understand different aspects of garbage collection, Garbage collectionIt is the process by which shared computer memory is cleaned which is currently being put to use by a running program when that program no longer needs that memory. With garbage collection, that freed memory can be used by another program.There are two methods used by python for memory management −Reference countingGarbage collectionPython’s garbage collection is automatic but in some ... Read More

Using WHERE BINARY in SQL

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

3K+ Views

The binary keyword can be used after WHERE clause to compare a value with exact case sensitive match.The following is an example −Case 1 − Case insensitive matchThe query is as follows −mysql> select 'joHN'='JOHN' as Result;The following is the output −+--------+ | Result | +--------+ | 1 | +--------+ 1 row in set (0.00 sec)In the above sample output, the result is true while we know joHN and JOHN are two different words. This is not a case sensitive match.Case 2 − If you want case sensitive match, use the binary keyword.The query is ... Read More

MySQL Select to Get Users Who Have Logged in Today

Chandu yadav
Updated on 30-Jul-2019 22:30:24

374 Views

To get the users logged in today, use the below syntax. Here, we are expecting that your datetime field is a string type −select yourColumnName1, yourColumnName2, yourColumnName3, ...N from youTableName WHERE STR_TO_DATE(yourColumnName1, ‘format’') =CURDATE();Let’s say we have the following “DateEqualToday “ table that stores users first and last name with the login date −+------+------------+-----------+------------+ | Id   | First_Name | Last_Name | LoginDate  | +------+------------+-----------+------------+ |    1 | James      | Smith     | 20-12-2018 | |    2 | Carol      | Taylor    | 21-12-2017 | |    3 | John       ... Read More

Sort Column in MySQL with 0 at the End

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

108 Views

You can sort a column, with 0 come last with the help of ORDER BY. The syntax is as follows −select *from yourTableName order by yourFieldName = 0, yourFieldName;To understand the above concept, let us create a table. The query to create a table is as follows −mysql> create table SortColumnZeroAtLastDemo    −> (    −> RankNumber int    −> ); Query OK, 0 rows affected (1.40 sec)Now you can insert records in the table using the following query −mysql> insert into SortColumnZeroAtLastDemo values(100); Query OK, 1 row affected (0.20 sec) mysql> insert into SortColumnZeroAtLastDemo values(0); Query OK, 1 ... Read More

Display Sub List of ArrayList in Java

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

779 Views

The sub-list of an ArrayList can be obtained using the java.util.ArrayList.subList() method. This method takes two parameters i.e. the start index for the sub-list(inclusive) and the end index for the sub-list(exclusive) from the required ArrayList. If the start index and the end index are the same, then an empty sub-list is returned.A program that demonstrates this is given as followsExample Live Demoimport java.util.ArrayList; import java.util.List; public class Demo { public static void main(String[] args) { ArrayList aList = new ArrayList(); aList.add("Apple"); ... Read More

8085 Program to Swap Two 8-Bit Numbers

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

5K+ Views

In this program we will see how to swap two numbers.Problem StatementWrite 8085 Assembly language program to swap two 8-bit number stored at location 8000Hand 8001H.DiscussionIn 8085, there is an instruction XCHG. Using this we can swap the contents of DE and HL values. We are taking the numbers and storing them into H and D, then using XCHG the contents are swapped.InputAddressData......8000CD800134......Flow DiagramProgramAddressHEX CodesMnemonicsCommentsF0003A, 00, 80LDA 8000HLoad the first number into AF00367MOV H, AStore the number into HF0043A, 01, 80LDA 8001HLoad the second number into AF00757MOV D, AStore the number into DF008EBXCHGExchange DE and HLF0097CMOV A, HTake H content ... Read More

Request Permission Programmatically to Use Location Services in iPhone iOS

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

294 Views

To request location services permission in ios with swift we can use the CLLocationManager.We’ll do this with help of a sample project. So, create a new project. First, we need to create a locationManager object, so in your view controller.var locationManager = CLLocationManager()Now, we, first of all, we need to check if the location services are enabled on the device or not. To check this we’ll useCLLocationManager.locationServicesEnabled() function, which returns a Boolean value showing whether the location service on the device is active or not.if CLLocationManager.locationServicesEnabled() {    print("permissions allowed") } else {    locationManager.requestAlwaysAuthorization()    locationManager.requestWhenInUseAuthorization() }In the example ... Read More

Vertically Align Numeric Values in Java Using Formatter

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

509 Views

To vertically align numeric values in Java, use Formatter. For working with Formatter class, import the following package.import java.util.Formatter;Take an array −double arr[] = { 2.5, 4.8, 5.7, 6.5, 9.4, 8.4, 9.5, 10.2, 11.5 };While displaying this double array values, use the %f to set spaces −for (double d : arr) { f.format("%12.2f %12.2f %12.2f", d, Math.ceil(d), Math.floor(d)); }Above, we have also set the decimal places i.e. 12.2f is for 2 decimal places.The following is an example −Example Live Demoimport java.util.Formatter; public class Demo { public static void main(String[] argv) throws Exception { ... Read More

Swap Two 8-Bit Numbers Using Direct Addressing Mode in 8085

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

699 Views

In this program we will see how to swap two numbers in direct addressing mode.Problem StatementWrite 8085 Assembly language program to swap two 8-bit number stored at location 8000H and 8001H using direct addressing mode. DiscussionIn this case we are taking the number from memory by using the HL pair. The HL pair is storing the address of the data item. We are taking the first number into B register, and the second number to A register, then storing the content of B to the next position, and storing the value of A into first position.InputAddressData......8000CD800134......Flow DiagramProgramAddressHEX CodesMnemonicsCommentsF00021, 00, 80LXI H, ... Read More

Advertisements