teleren/devto huggingface dataset:
Can you use == for strings in java?
Tags: java, opensource, oop, computerscience
Published: 2020-11-27 19:55:01

In this article, I will explain different methods to make you understand better, of using (==) for strings in java. We can use “ == “ in java, but it has few exceptions and is clearly stated below

#Approach
##EqualsTo() Method
In java, we can use “ == “ operator to compare two strings which has same or different values.
In the below example, I have used two strings named str1 and str2. We have used equals to operator(==) to compare these two strings. Thus the output value is obtained.

###Example 1

```
public  class EqualsToStrings 

{

Public static void main(String[ ] args)

{

String str1 = “Kodlogs”;

String str2 = “Kodlogs”;

if(str1 == str2)

System.out.println(“ They are equal”);

else

System.out.println(“They are not equal”);

}

}
```

###Output

`They are equal`

##Equals() Method
* Coming to example2, we have declared two String constructors to create these strings str1, str2. If we use (==) operator i.e., equals to(), then it shows wrong output, because they compare the reference of strings.
* So we need to use equals() method for comparing two constructor strings because it compares the values of strings.

###Example
```
public  class EqualsToStrings 

{

Public static void main(String[ ] args)

{

String str1 = new  String(“Kodlogs”);

String str2 = new String(“Kodlogs”);-

if(str1.equals(str2))

System.out.println(“ They are equal”);

else

System.out.println(“They are not equal”);

}

}
```
###Output
`They are equal`

##EqualsTo() in place of Equals()
[Read more](https://www.kodlogs.com/blog/2463/can-you-use-for-strings-in-java)
Create Custom Scrollbar
Tags: css, html, javascript, beginners
Published: 2020-11-27 19:28:50

**Set the SCROLLBAR width**
Here is Code

```css
::-webkit-scrollbar {
  width: 20px;
  -webkit-transition: all 300ms;
  transition: all 300ms;
}
```
<br>
**Set the SCROLLBAR track**
Here is Code

```css
::-webkit-scrollbar-track {
  background-color: #EDF2F4;
}
```
<br>
**Set the SCROLLBAR thumb**
Here is Code

```css
::-webkit-scrollbar-thumb {
  border-radius: 7px;
  background: #2B2D42;
  border-left: 3px solid #EDF2F4;
  border-right: 3px solid #EDF2F4;
}
```
<h3>Now i am sure you can Create Successfully <b>Am I Right ?</b></h3>
<br>
Thanks for watching guys also apply a custom scrollbar to your Website I hope you understand everything steps.
Also visit our website <a target="_blank" href="http://mycodemagic.com">mycodemagic</a>
Difference between break and continue in PHP
Tags: php, webdev, computerscience
Published: 2020-11-27 19:27:34

Php allows you to control the flow of loops and switch, to accomplish this PHP has a ’ Break ‘and Continue statement. Both the break and continue to have their own importance and priority over each other depending on what you expect from the loop or want to perform some specific actions.  

The main difference between Break and continue Statement is that break terminates all remaining iterations prematurely when specific conditions come true while continue statement will skip an iteration when you condition comes true and continues looping other iterations. We will check both of them one by one based on their functionality and purpose of use.

#Break Statement:

Break statement in PHP is used to terminate all remaining iterations when the desired condition is fulfilled or comes true by loop or switch. For example, you have a loop of 10 iterations and if you achieve your result at the 5th iteration remaining iterations will be killed. This very helpful to reduce code execution time. We will further check this one example.

```
<html>
<body>
<?php  
for ($i = 0; $i < 10; $i++) {
  if ($i == 5) {
    break;
  }
  echo "The number is: $i <br>";
}
?>
</body>
</html>
```
In the above program, we have a FOR loop with 10 iterations and we want to break out control when we reach iteration number 5, the loop started and we have output up to  5 iterations, and control was prematurely terminated.
[Read more](https://www.kodlogs.com/blog/2477/difference-between-break-and-continue-in-php)
Count occurrences of character in string javascript
Tags: javascript, webdev, html, php
Published: 2020-11-27 19:21:14

When we offer a text area it may be the case that we have a limit of the characters to be entered. In this case, it would be good to offer the user the number of characters that have been inserted, and in passing the words.

The first thing we are going to do is create a text area in HTML using the TEXTAREA element.

Inside the form, we include a button, which when pressed will invoke the wordCount () method, which contains all the code of the example to count characters and words in JavaScript.

Inside the wordCount method, the first thing to do will be to get the text from the text area (save redundancy). We will do this through the getElementById method.
`textArea = document.getElementById ("area"). value;`

Once we have the text, we obtain the number of characters through its length (length property).

`numberCharacters = text.length;`

The next thing is to count the words that the text has. In order to do this, we will use the split function which TRACES a string into substrings taking as a cut character the one we pass as a parameter, and leaving the result in an array of words.

`DividedAreaText = TextArea.split ("");
numberWords = textAreaDivided.length;
`

[Read more](https://www.kodlogs.com/blog/2542/count-occurrences-of-character-in-string-javascript)
How to compare two Arraylist in java?
Tags: java, oop, computerscience
Published: 2020-11-27 19:18:24

In this article, we will learn what is an ArrayList and different methods of comparing an ArrayList in java. An example program will be described below for the audience to understand.

#ArrayList in JAVA
Unlike the normal array, ArrayList is a resizable array where one can add, remove, access, or change an element in an array at any time. This is not possible with a normal array and the syntax for this ArrayList is shown below as follows.

##Syntax
`ArrayList< DataType> arrayListname = new ArrayList< DataType>();`

###Approach
* I have stated an example regarding the usage of equals() method in java to compare two ArrayLists.
* As far as syntax is concerned, boolean equals(Object o). It returns true if the object matches with the list or else return false
* I have declared two strings ArrayLists named list1 and list2, and by using java,util.ArrayList package, I have added list items to list1 and list2.
* In the next step, I have compared two lists by using the equals() method, such that it returns true, as both the items in the lists are ideal.
* In the last step, I have added another item to the list1, but not list2 and compared once again and the final output is resulted as false because the number of items is more and not equal.
This is how we compare two ArrayLists and I have used the equals( ) method as an example.
* There are other methods like the removeAll(), retainAll(), contains() methods can also be used for comparison. 
[Read more](https://www.kodlogs.com/blog/2572/how-to-compare-two-arraylist-in-java)
Remove PHP extension from URL using htaccess
Tags: php, webdev
Published: 2020-11-27 19:14:06

User-friendly URLs show a great impact and reputation of your web pages or web address. For example, www.kodlogs.com is easier to understand by users not familiar with a backend or codding language rather than your address looks like www.kodlogs.php.com . to make our pages URL or sites user friendly we need to make some changes in .htaccess file. In this topic, you will learn a full guide to how to change or remove file extensions of webpages.

#Method to remove file extensions from the webpage
Web File/page extension can be removed by changing or adding few lines of code in the “.htaccess” file. This an ASCII file you can edit it and can change easily the configuration.  the most important thing is that .htaccess is the file and not the file type or extension. You can make changes in this file either by cPanel access or if your file is a local server in the system you can also find and change settings.

##How to change .htaccess in cPanel
Here are some steps you need to follow to find and make changes in the .htaccess file.

* First, you need to login into the cPanel account.·  
* After logging in go to FILES section file manager.
* On the top right corner of the Panel click the setting icon to open the setting.
* On the preferences window that will appear enable the option of view hidden files and save to apply changes made.
* Here you will find the .htaccess file click It to open, in case if you cannot find or the file is not there you need to create the file.
* On top Manu click edit.
* Once the file open for editing, copy the following lines, and save the file by clicking save. [Read more](https://www.kodlogs.com/blog/2606/remove-php-extension-from-url-using-htaccess)
How to pass variable value from one page to another in PHP?
Tags: php, webdev
Published: 2020-11-27 19:11:27

#Syntax:
```<?php
     session_start();
     session_register('variable_name');
     $_SESSION['variable_name']=variable_value;
?>
```

##Step 1
Begin your localhost server as Apache, etc. Finish writing the HTML tags and write the beneath code within the BODY section. Then save the file with the format ‘form1.php’ in the local directory of your localhost. Later on, in your web browser type localhost address followed by ‘\form1.php’ 
```
<form method="POST" action="form2.php"> 
	<pre>Name: <input type="text"
		name="user_name"> 
	</pre> 
	
	<pre>Email Address: <input type="text"
		name="user_email_address"> 
	</pre> 
	
	<pre>Mobile Number: <input type="number"
		name="user_mobile_number"> 
	</pre> 
	
	<input type="submit" value="Next"> 
</form> 
```

Requested information will be paused to the PHP page connected with the form (action=”form2.php”) with the use of the post method. After that submitted information will be stored in the session array

##Step 2
Return the process of saving the file as explained over. Remember use the file name ‘form2.php’. At the time you click ‘Next’ on form1.php page. So, this page will be requesting the college/ company name, city, state user is in and the course applicant is applying for.
###Code:
```
<?php 

// Initialize the session 
session_start(); 
	
// Store the submitted data sent 
// via POST method, stored 

// Temporarily in $_POST structure. 
$_SESSION['name'] = $_POST['user_name']; 

$_SESSION['email_address'] 
		= $_POST['user_email_address']; 

$_SESSION['mobile_number'] 
		= $_POST['user_mobile_number']; 
		
?> 

<!-- Form for other details--> 
<form method="POST" action="form3.php"> 
	
	<pre> 
		Company/College: 
		<input type="text" name="college_name"> 
	</pre> 
	
	<pre> 
		City: 
		<input type="text" name="city"> 
	</pre> 
	
	<pre> 
		State: 
		<input type="text" name="state"> 
	</pre> 
		
	<pre> 
		You're a: 
		<input type="radio" name="profession"
				value="Student">Student 
		
		<input type="radio" name="profession"
				value="Working Professional"> 
				Working Professional 
	</pre> 
	
	<pre> 
		Course: 
		<select name="course"> 
			<option value="DSnA"> 
				Data Structures and Algorithms 
			</option> 
			
			<option value="Gate_test"> 
				GATE Mock Test 
			</option> 
			
			<option value="Mock_interview"> 
				Mock Interviews 
			</option> 
			
			<option value="Machine_learning"> 
				Machine Learning 
			</option> 
		</select> 
	</pre> 
	<br> 
		
	<pre> 
		<input type="checkbox"
			name="terms_and_conditions"> 
			Terms and Conditions 
	</pre> 
	<br> 
	
	<input type="submit" value="Register"> 

</form> 
```
It will be redirected you to this page. [Read more](https://www.kodlogs.com/blog/314/how-to-pass-variable-value-from-one-page-to-another-in-php)
S2E9 Learn JMeter Series - Boundary Extractor
Tags: performance, testing, webperf, tutorial
Published: 2020-11-27 19:11:02

Welcome to Learn JMeter Series!

In this Season Two, Episode Nine, you will learn following:

🔹 CSS Selector Extractor in JMeter

{% youtube _KxVjJFohjg %}

☑ Buy me a tea 🍵 : https://www.buymeacoffee.com/qainsights
☑ [My Blog](https://qainsights.com)
☑ [My Udemy Course](https://www.udemy.com/course/performance-testing-using-truweb)
What is the use of self in python?
Tags: python, oop, computerscience
Published: 2020-11-27 19:06:47

The reason you need to use self. is because Python does not use the @ syntax to refer to instance attributes. Python decided to do methods in a way that makes the instance to which the method belongs be passed automatically, but not received automatically: the first parameter of methods is the instance the method is called on. That makes methods entirely the same as functions, and leaves the actual name to use up to you (although self is the convention, and people will generally frown at you when you use something else.) self is not special to the code, it's just another object.

Python could have done something else to distinguish normal names from attributes -- special syntax like Ruby has, or requiring declarations like C++ and Java do, or perhaps something yet more different -- but it didn't. Python's all for making things explicit, making it obvious what's what, and although it doesn't do it entirely everywhere, it does do it for instance attributes. That's why assigning to an instance attribute needs to know what instance to assign to, and that's why it needs self..

#To add to the other answers...

You could declare variables within a class without using the self reference, but then those variables would be shared by all instances of that class, which may not be what you intended. In your example, self.age = age and self.name = name are declaring "instance variables" (as opposed to "class variables"), the values of which would be unique to the instantiated objects of that class. Otherwise, all students would have the same name and age!

**Let's say you have a class ClassA which contains a method methodA defined as:**
[Read more](https://www.kodlogs.com/blog/2329/what-is-the-use-of-self-in-python)
Help using Node addons to call c++
Tags: help, node, cpp, addon
Published: 2020-11-27 18:48:32

I'm currently working with trying to call c++ in js. I've been successful using [nan](https://www.npmjs.com/package/nan) for passing and returning primitives.

But when I tried passing/returning `std::string` it got harder. I [read in the addon docs](https://nodejs.org/api/addons.html), "Unless there is a need for direct access to functionality which is not exposed by N-API, use N-API."

Any advise on how to proceed? Should I stick with `nan` or switch to `N-API`? I'm eventually going to work with c++ classes and structs.
#7 Dropping a Collection
Tags: mongodb
Published: 2020-11-27 18:45:50

To drop a collection:
`mongoose.connection.collections.mariochars.drop()`
note that we're writing `mariochars` (pluralized) and not `mariochar` but we've declared the collection as `mariochar`. This is the way mongodb works.

To drop the collection before every test so that the result of one test do not affect the other test by using `beforeEach`
```
const mongoose = require('mongoose');mongoose.Promise = global.Promise 
before(function(done){
    // Connect to mongodb
    ...
})
beforeEach(function(done){
    mongoose.connection.collections.mariochars.drop()
    done()
})
```
Compare two string in C++
Tags: cpp, oop, computerscience
Published: 2020-11-27 18:45:08

In this post, we will see how to know if two strings are equal in ANSI C since we cannot simply use the operator ==to compare strings, they are a complex thing.

#Table of contents:

* strcmp function in C.
* Compare strings in C using strcmp.
* Know if two strings are equal using strcmp.
Let's see how to use strcmp to compare strings in C and find out if both are the same since strings are actually a set of characters within ANSI C.

##Strcmp function in C:
As in PHP, in C there is the function strcmpthat means "string compare". This function can return 0, a number greater than 0, or a number less than 0.

I know, it sounds confusing but let's see.

The function will strcmpreturn if the strings are equal. In case the first is "less" than the second, it will return a negative number, and finally if the first is greater than the second, it will return a positive number.

Usually, these numbers are 0, -1 and 1, but we can make the comparisons based on 0 (that is if it is less than zero, equal to zero or greater than zero). [Read more](https://www.kodlogs.com/blog/2318/compare-two-string-in-c)
How to solve indentation error in python?
Tags: python, oop, computerscience
Published: 2020-11-27 18:41:32

All of your class contents (doc strings, methods, and class variable definitions) need to be indented to the same level.

#Currently either :

The doc string above your def __init__ is indented too far or
The __init__ method isn’t indented enough
It is up to you to choose which one is right - but PEP8 would say that the doc string is indented too far.

##BTW - The normal format for a doc string is :

1st line is a one line summary
then a blank line
and the rest of the docstring is a more details description of the class.
or

1st line is a one line summary
SO maybe your docstring should be :

"""
Class for storing movie data

This class is for storing a large amount of movie
data such as:
[Read more](https://www.kodlogs.com/blog/2351/how-to-solve-indentation-error-in-python)
Difference between error and exception in java
Tags: java, oop, computerscience
Published: 2020-11-27 18:39:49

In ths article, we will learn the major “Differences Between Error and Exception in Java”
"Throwable" as root for errors and Java exception hierarchy. "Error" is a critical condition that can not be handled by the program code. "Exception" is an exceptional situation that can be handled by the program code.
The significant difference between error and exception is that the error is caused due to lack of system resources, and exceptions caused by your code. Let us learn another difference between mistakes and exceptions .

#Definition of Errors

"Error" is a subclass of the built-in class "Throwable" it. The error is a critical condition that occurs due to lack of system resources, and can not be handled by the program code. Mistakes can not be restored by any means because they can not be created, removed, captured or answered. Errors caused by a catastrophic failure which can not usually be handled by your program.
Error type always checked, because the compiler has no knowledge of the incident. Errors always occur at run-time environment. Errors can be explained by way of example, the program has an error of stack overflow, out of memory errors, or errors system crashes, this type of error is due to the system.
This code is not responsible for the error. The consequences of the occurrence of the error is that the program will be terminated abnormally.

##Definition of Exception

"Exception" is also a subclass of the built-in class "Throwable". Exceptions are exceptional conditions that occur in the runtime environment. Most of the time exception because the code of our program. However, exceptions can be handled by the program itself, as an exception can be restored. Exceptions are handled by using three key words "try", "catch", "throw". Syntax of exceptions are:
1. try {
2. // write your code here
3.} catch (Exception type) {
4. // write your code here
5.}
In the above code, code written in the try block is the code that you want to monitor for exceptions. If an exception occurs in the try block, it is thrown using the "throw" keyword. Exceptions thrown can be caught by "catch" block of code above. "Exception type" is the type of exception that has occurred.
In simple words we can say that the error occurs because the code is inappropriately called exceptions. For example, if the class was not found, or the requested method was not found. The types of exclusion is because the code in this program; This system is not responsible for the kinds of exceptions.
Exceptions are classified as "checked" and "unchecked". unchecked exceptions are not in the knowledge of the compiler because they occur during runtime while, the compiler has knowledge of checked exceptions because they are known to the compiler during compile time. [Read more](https://www.kodlogs.com/blog/2214/difference-between-error-and-exception-in-java)
Difference between static and final in Java
Tags: java, oop, computerscience
Published: 2020-11-27 18:37:18

#Definition of Static
Static could be a keyword, applicable to the categories, variables, methods, and blocks. the category members, class, and blocks will be created static mistreatment “static” keyword ahead of the name of the category members, class, and blocks severally. once a category member is asserted as static, it becomes world for all alternative members of the category.
•    A static variable acts sort of a world variable for all alternative knowledge members of the category.
•    A static variable will be accessed before any object of the category exists.
•    A static variable will be accessed with the category name within which it's outlined followed by the dot(.) operator.


##Static strategies
•    A static technique will solely decision alternative static strategies solely.
•    A static technique will access static knowledge solely.
•    A static technique can't be remarked “this” or “super” in any conditions.
•    A static technique will be accessed with the category name within which it's outlined followed by the dot(.) operator.


###Static category
•    Java will have the idea of nested static category. The outer category can't be created static whereas the innermost category will be created static.
•    A static nested category can't access the non-static member of the outer category.
•    It will solely access the static members of the outer category.


####Static Block
Static block is dead just once once the category is loaded. accustomed initialize the static variables of the category. [Read more](https://www.kodlogs.com/blog/2550/difference-between-static-and-final-in-java)
Deploying to your local IP address with Nextjs.
Tags: nextjs
Published: 2020-11-27 18:26:40

There's no doubting Nextjs as a powerful framework for building production-grade, hybrid web applications.

Sometimes, when building responsive applications, it is very important to be able to test on mobile and other devices in real-time. `create-react-app` does this out of the box, with next, we need to follow a few steps.

(It is important to note that for this to work, all the devices you want to test on have to be connected to the same network.)


* Open your terminal and run the command `ipconfig` for windows or `ifconfig` for MacBooks. You'll see the network you're currently connected to, the IPv4 address being the current local IP address.

Now to the deployment.

On your terminal, run `yarn dev -H [your IP address]` or `npm run dev -H [your IP address]`. For example, `yarn dev -H 102.168.8.100`. This creates a server with your application hosted on your local IP address, and the link shows up on your terminal using the default port of 3000, or any port you configured your app to run on.

That link can then be used on any device, and any changes you make to your app will be updated in real-time.

Happy Building!