Featured Editorial

Introduction

If you are a Java developer coming to Kotlin, you might have wondered how to use a language construct that is similar to the try-with-resource statement in Java to automatically close Autocloseable/Closeable resources for you.

Luckily, Kotlin provides the inline extension function use() that provides similar functionality to the …

Continue Reading
Introduction

In Java, a common way to express a type that is a combination of two or more types is to just create an interface that extends the other types. The problem with this approach is that your code might be littered with interface declarations, polluting your code and namespace.

Continue Reading

Recommended Topics

Member Avatar

## Introduction ## If you are a Java developer coming to Kotlin, you might have wondered how to use a language construct that is similar to the try-with-resource statement in Java to automatically close Autocloseable/Closeable resources for you. Luckily, Kotlin provides the inline extension function `use()` that provides similar functionality to the try-with-resource block. In this tutorial, we will learn how to use the `use()` extension function with Autocloseable resources. ## Goals ## At the end of the tutorial, you would have learned: 1. How to use the `use()` extension function. 2. How it differs from the Java try-with-resource statement. …

2
10
Member Avatar

## Introduction ## In Java, a common way to express a type that is a combination of two or more types is to just create an interface that extends the other types. The problem with this approach is that your code might be littered with interface declarations, polluting your code and namespace. But there is a solution to this problem, and that is the usage of Intersection Type. The Intersection Type is somewhat of an elusive language feature in Java, so in this tutorial, we will learn how to use it on our code. ## Goals ## At the end …

2
11
Member Avatar

hi there i have some python coding which i need to convert to java can ne1 help me please email me back if you can help then i will show you the coding much appriciated

Member Avatar
1
94,351
Member Avatar

The alarm clock application works by setting a certain time and then it perform a certain task eg:sound an alarm, display a messagebox test message. But the problem comes where i need to snooze(delay) the alarm clock for a certain time period like 10 second... Then it will re-initialise the initial alarm clock function. i tried this but it doesn't work... Why? or is there other methods to snooze the alarm clock? DateTime SnoozeTime; // global private void btnSNOOZE_Click(object sender, EventArgs e) { pnlDisplay.BackColor = SystemColors.Control; myPlayer.Stop(); SnoozeTime = DateTime.Now.AddSeconds(10); Time2.Enabled = true; } private void Time2_Tick_1(object sender, EventArgs e) …

Member Avatar
-1
1,123
Member Avatar

Hi, everybody. I write bots and decided to share my experience of writing bots on the [Chat API] platform, maybe it will be interesting to someone We’ll tell you how to write a simple bot on PHP using API WhatsApp. A demo bot will react on commands of ordinary Whatsapp messages to answer them. Now our demo bot features the following functions: Displaying the list of commands Displaying the ID of the chat Displaying the current bot server time Displaying your name Sending files of different formats (pdf, jpg, doc, mp3, etc.) Sending pre-recorded voice messages Sending geo-coordinates (geo-locations) Creating …

2
11
Member Avatar

What I would like to do is to register a couple of shortcuts to move the mouse cursor. The cursor should jump from the one square area of the screen to the other. The question that comes to mind first is: which keys are not used (or at least not often) so they can be used for this purpose? Of course, the arrow keys stand out as good candidates. Anybody out there who can enlighten me? Thanks

Member Avatar
0
65
Member Avatar

## Introduction ## In Kotlin, we can extend classes without subclassing via extension functions and extension properties. This feature is useful whenever we want to extend 3rd party libraries or final classes. In this tutorial, we will learn what extension functions and extension properties are, and how to create our own. ## Goals ## At the end of the tutorial, you would have learned: 1. What extension functions are. 2. What extension properties are. 3. How to create extension functions. 4. How to create extension properties. ## Prerequisite Knowledge ## 1. Basic Kotlin. ## Tools Required ## 1. An IDE …

2
26
Member Avatar

## Introduction ## `launch()` and `async()` are two of the most common coroutine builders to use in Kotlin, but they are somewhat different in usage. `launch()` returns a `Job` object, which can be used to cancel or perform other operations on the underlying coroutine. If our coroutine lambda returned a useful result, then there is no way to access it via this Job object. `async()` is different to `launch()` because it returns a `Deferred<T>` object, where `T` stands for the result returned from its lambda expression. `Deferred<T>` is actually a **child** of Job, and via a Deferred object, we can …

2
23
Member Avatar

## Introduction ## In this tutorial, we will look at the RxJava `mergeWith()` and `concatWith()` operators. Amongst others, they are used to combine Observables together. All of the RxJava operators have ambiguous names, and behave differently, so let us take a look at 2 operators, `mergeWith()` and `concatWith()`, to see how they are different. ## Goals ## At the end of the tutorial, you would have learned: 1. How to use the RxJava `mergeWith()` operator. 2. How to use the RxJava `concatWith()` operator. ## Prerequisite Knowledge ## 1. Intermediate Java. 2. Basic RxJava 3. ## Tools Required ## 1. A …

2
18
Member Avatar

## Introduction ## RxJava 3 includes 5 core classes: 1. Flowable, 2. Observable, 3. Single, 4. Completable, 5. Maybe. This tutorial aims to teach the basic concepts behind Observable, which serves as a foundation for understanding the other 4 classes. ## Goals ## At the end of the tutorial, you would have learned: 1. How to create an Observable. 2. How to subscribe to an Observable using an Observer. 3. How to subscribe to an Observable using Consumers. ## Prerequisite Knowledge ## 1. Intermediate Java. 2. Basic knowledge of the Observer pattern. ## Tools Required ## 1. A Java IDE …

2
20
Member Avatar

i have code for write on console and change the text color and backcolor and clear screen(and much more) inside of a nice class console. these function change the text color and back color: void SetColorAndBackground(int ForgC, int BackC=0) { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), ForgC|(BackC<<4) ); } but is there any way for blink the text?

Member Avatar
0
2,124
Member Avatar

## Introduction ## With coroutines in Kotlin, we are able to execute suspending functions without blocking the current thread. By default, most coroutine builder functions use the `Dispatchers.Default` context, but it is also possible to use other implementations of `CoroutineContext`. In this tutorial, we will learn about the 2 `CoroutineDispatchers`: **Default** and **IO**. ## Goals ## At the end of the tutorial, you would have learned: 1. The difference between: a. `Dispatchers.Default`. b. `Dispatchers.IO`. 2. How to use them. ## Prerequisite Knowledge ## 1. Basic Kotlin. 2. Basic Coroutines. ## Tools Required ## 1. A Kotlin IDE such as IntelliJ …

2
31
Member Avatar

## Introduction ## The `java.nio.file.Files` class includes many convenient methods to read file attributes, but sometimes these convenient methods just are not enough to meet our needs. In this tutorial, we will go over 5 ways to use the `Files` class to read file attributes so you can choose the best way for your use case. ## Goals ## At the end of the tutorial, you would have learned: 1. 5 different ways to view file attributes with **Java NIO**. ## Prerequisite Knowledge ## 1. Basic Java. 2. Java NIO/IO. ## Tools Required ## 1. A Java IDE such as …

2
23
Member Avatar

Hi pals, I am a Newbie in C++ Programming field. I plan to add graphics.h header class in Dev -C++ Version 4.9.9.2 from Bloodshed which is come along with Borland Compiler. I follow the Steps in URL : [url]http://www.uniqueness-template.com/devcpp/#step2[/url] But I Got Error in the Sample code which test the Working , Please Help me to get away from this problem . I am waiting to hear from you. Regards Anes P.A:'(

Member Avatar
1
26,047
Member Avatar

hello , i wanna do something as below but the problem that names and address out of the connection query are empty how can i assign them and the send them to the page? app.get('/reports', (req, res)=>{ let sql = "SELECT DISTINCT name from users_table ;"; let names; let query = connection.query(sql,(err,results) => { if(err) throw err; names=results }); let sql2 = "SELECT DISTINCT address from users_table ;"; let addresss ; let query2 = connection.query(sql2,(err,results) => { if(err) throw err; addresss=results }); res.render('reports',{ title:'Reports ', names:names, addresss:addresss, }) });

Member Avatar
1
50
Member Avatar

Just started learning PEP/8 what would the correct way to convert numbers into roman numericals? for exemple How can input let say 6 and have it come out as VI in the output? I know what i did is far from being the correct way to do things as i only print out the roman letters when input specific numbers. BR main ;******* main () nb: .BLOCK 2 I: .EQUATE 1 II: .EQUATE 2 III: .EQUATE 3 IV: .EQUATE 4 V: .EQUATE 5 X: .EQUATE 10 L: .EQUATE 50 C: .EQUATE 100 D: .EQUATE 500 M: .EQUATE 1000 char00: .byte …

Member Avatar
0
64
Member Avatar

## Introduction ## When working with an application with a global user base, there is usually a need to display text, numbers, currency, date, and time in multiple localized formats. For example, the **en-US** (*English-USA*) version of the date September 22, 2021 is written as 22 сентября 2021 г. when the locale used is **ru-RU** (*Russian-Russia*). In this tutorial, we will learn how to format currency and date in localized formats using `java.time.*` and `java.text.*` classes. ## Goals ## At the end of this tutorial, you would have learned: 1. How to format currency based on locale. 2. How to …

2
51
Member Avatar

## Introduction ## Although not included in the headlines, the release of JDK 17 also added 3 sets of new methods to the class `java.lang.Process`: 1. `inputReader()` to read from stdout. 2. `inputWriter()` to write to stdin. 3. `errorReader()` to read from stderr. In this tutorial, we are going to learn how to use `Process.inputReader()` to read stdout from external processes. ## Goals ## At the end of this tutorial, you would have learned: 1. How to read stdout from an external process. 2. What command injection is. ## Prerequisite Knowledge ## 1. Basic Java. 2. Java IO/NIO. ## Tools …

2
36
Member Avatar

Hello everyone, I've been using this website and it has helped me with it's hundred of solved cases, but I couldn't find one appropriate for this one. I have created a Menu() function that looks like this: [CODE=C]int Menu() { int i; printf("MENU\n\n"); printf("1 - ...\n"); printf("2 - ...\n"); printf("3 - ...\n"); printf("4 - ...\n"); printf("5 - ...\n\n"); printf("Choose: "); scanf("%d",&i); printf("\n\n"); return i; }[/CODE] And I have been calling it using this on main(): [CODE=C]void main() { int op; op = Menu(); switch(op) { case 1: funct1(); break; case 2: funct2(); break; case 3: funct3(); break; case 4: funct4(); …

Member Avatar
1
11,804
Member Avatar

Hey guys, I want to Know is there any way to get sum of numbers which entered in single textbox in VB6 as a example; i have textbox named txt1 in that user can type any value (12+23+34+12....) (separate the values by adding "+").when the user click the command button, i want to get the Sum of those values to a variable/textbox or label. i searched over the internet and found a option to get values separatly by using "split" funtion, but i cant get sum of those. plese help me.

Member Avatar
1
6,985
Member Avatar

Parse error: syntax error, unexpected T_IF in H:\xampp\htdocs\login.php on line 74 i don't see any mistake here? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!-- --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="keywords" content="" /> <meta name="description" content="" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Yakity Yak</title> <link href='http://fonts.googleapis.com/css?family=Oswald:400,300' rel='stylesheet' type='text/css'> <link href='http://fonts.googleapis.com/css?family=Abel|Satisfy' rel='stylesheet' type='text/css'> <link href="style.css" rel="stylesheet" type="text/css" media="screen" /> </head> <body> <div id="wrapper"> <p><!-- end #header --></p> <div id="header" class="container"> <div id="logo"> <h1><a href="#">Yakity Yak</a></h1> </div> <div id="menu"> <ul> <li class="current_page_item"><a href="../../Documents/Unnamed Site 2/index.html">Homepage</a></li> <li><a href="../../Documents/Unnamed Site 2/trip.html">Destinations</a></li> <li><a href="#">contact </a></li> <li><a href="#">Login</a></li> <li></li> <li></li> </ul> </div> </div> <blockquote> <blockquote> …

Member Avatar
1
4,235
Member Avatar

So i have multiple web pages containing multiple episodes, what I'm trying to implement is a search box in the nav bar which will bring up the episode/category your looking for, nothing too over complicated. If anyone would be willing to point me in the right direction that would be great. I already have some php built in for my header and footer that way i can configure one file and it updates all. Cheers guys

Member Avatar
1
49
Member Avatar

can anyone help me to make an app

Member Avatar
1
187
Member Avatar

#include<iostream> #include<conio.h> using namespace std; struct marks{ int phy[10]; int math[10]; int chem[10]; }; int main(){ struct marks m[20]; int i,n; cout<<"Enter the number of students : " << endl; cin >>n; for(i=0;i<n;i++){ cout<<"\nEnter Physics marks: " << endl; cin >> m[i].phy; [error here] cout<<"\nEnter Maths marks : "<< endl; cin >> m[i].math; cout<<"\nEnter Chemistry marks : "<< endl; cin >> m[i].chem; } cout<<"\nStudents mark details : \n"<< endl; for(i=0;i<n;i++){ cout<<"\nMarks of Student"<< i+1 <<" : "<< endl; cout<<"\nPhysics marks: "<< m[i].phy<< endl; cout<<"\nMaths marks: "<< m[i].math<< endl; cout<<"\nChemistry marks: "<< m[i].chem<< endl; cout<<"\n"<< endl; } return 0; } //There …

Member Avatar
1
46
Member Avatar

Good morning, i have a section in a php page as per code: <div class="container section" id="afterHeader"> <div class="row"> <div class="tabs movies"> <a class="style1">1^ WEEK</a> <ul> <li><a href="#thu">GIO</a></li> <li><a href="#fri">VEN</a></li> <li><a href="#sat">SAB</a></li> <li><a href="#sun">DOM</a></li> <li><a href="#mon">LUN</a></li> <li><a href="#tue">MAR</a></li> <li><a href="#wed">MER</a></li> </ul I would need to replace the part <ul> </ul> part with this other code: <?php function myTab() { echo str_repeat('&nbsp;', 3); } function templateDay($start, $end) { $dayOfWeek = ['LUN', 'MAR', 'MER', 'GIO', 'VEN', 'SAB', 'DOM']; $toDay = date('N') - 1; for ($i = $start; $i < $end; $i++) { echo $dayOfWeek[$toDay] === $dayOfWeek[$i] ? "<a style='color:red'>" . 'OGGI' . …

Member Avatar
1
73
Member Avatar

The purpose of the program is to tell the user that the weekly salary is in on of three ranges, less than 200, between 200 and 800 and greater than 800. I need help knowing the error/s and need to add and use one additional preprocessor directive that might help with calculation or showing the results #include <iostream> using namespace std; int main() { const int MAX_HOURS_IN_WEEK = 168; const int MAX_WAGE = 100; const int LOWER_SALARY = 200; const int UPPER_SALARY = 800; int hourlyWage; int workHoursPerWeek; int weeklySalary; cout << "How many hours do you work per week?" …

Member Avatar
1
42
Member Avatar

I have a problem to do price data and i don't know to insert it into the coding this is question ![Screenshot_2021-09-23_015318.png](https://static.daniweb.com/attachments/4/7cc52f3407b6a914f395c8aaa4644c69.png) this is the coding that i have made <?php $page_title = 'Yoho Express!'; include ('includes/header.html'); ?> <form action="q2.php" method="post"> <p><h1><fieldset><legend>Enter your information in the form below:</legend></p></h1> <p><b>Departure day:</b> <?php //This programme is display in an array. $day = array (1 =>'Select', 'Saturday', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'); //the programme is display using the pull-down menu. echo '<select name="day">'; foreach ($day as $key => $value) { echo "<option value=\"$value\">$value</option>\n"; } echo '</select>'; ?></p> <p><b>Departure time:</b> <?php //This programme …

0
89
Member Avatar

**Requires:** 1. Python version 3.8 or newer 2. wxPython version 4.0 or newer 3. exif module 4. Windows with NTFS file system To ensure you have the required packages please run the following 1. python -m pip install --upgrade pip 2. pip install exif 3. pip install wxPython I have lots of digitized photos on my computer. To keep track of them I use two programs. The first is called [Everything Indexer](https://www.voidtools.com/). It's free, fast, and I use it daily. It maintains, in real time, a database of all files on your computer. The search window allows you to see …

Member Avatar
3
102
Member Avatar

## Introduction ## In Android development, the current recommended library for Dependency Injection is Hilt. The most obvious benefits of using Hilt are reduced boilerplate code and lifecycle-aware components(*and their associated annotations*). Hilt is a great library, but it is not perfect. Hilt is built on top of Dagger 2, so the terminologies and concepts are hard to understand for developers who did not use Dagger before being introduced to Hilt. This tutorial introduces Dagger 2 in its original form using Kotlin to make it easy for Kotlin-only developers to follow. The main feature that we are going to look …

2
41
Member Avatar

## Introduction ## In Java 8, `@Repeatable` was introduced and this is the recommended way to create repeating annotations. We still have to create a holder Annotation(*annotation that holds an array of other annotations*), but we no longer have to declare the holder Annotation at the callsite. This tutorial aims to show you the difference between the old way and the new way using `@Repeatable`. ## Goals ## At the end of this tutorial, you would have learned: 1. How to create your own custom Annotations. 2. How to create repeatable Annotations. ## Prerequisite Knowledge ## 1. Basic Java 2. …

2
28

The End.