kotlin中判斷字符串_Kotlin程序刪除字符串中所有出現的字符

kotlin中判斷字符串

Given a string and a character, we have to remove all occurrences of the character in given string.

給定一個字符串和一個字符,我們必須刪除給定字符串中所有出現的字符。

Example:

例:

    Input:
string = "includeHelp Delhi"
Output:
String after removing character : "includeelp Deli"

在Kotlin中刪除字符串中所有出現的字符的程序 (Program to remove all occurrences of a character in a string in Kotlin)

package com.includehelp.basic
import java.util.*
//Main Function, entry Point of Program
fun main(args: Array<String>) {
// InputStream to get Input
val scanner = Scanner(System.`in`)
//Input String
print("Enter String : ")
var str = scanner.nextLine()
//Input Character to Remove from String
print("Enter Character : ")
val c = scanner.next()[0]
//Replace character with Empty String
val newStr=str.replace(c.toString(),"",ignoreCase = true)
//Print String after Replacement
println("String after removing character : $newStr ")
}

Output

輸出量

Run 1:
Enter String : includeHelp Delhi
Enter Character : h
String after removing character : includeelp Deli
---
Run 2:
Enter String : corona virus global death rate
Enter Character : o
String after removing character : crna virus glbal death rate

翻譯自: https://www.includehelp.com/kotlin/remove-all-occurrences-of-a-character-in-a-string.aspx

kotlin中判斷字符串

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/542529.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/542529.shtml
英文地址,請注明出處:http://en.pswp.cn/news/542529.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Java9中使用jpa,jpa – eclipselink在Java 9上使用final字段進行靜態編織

我有一些JPA注釋字段,如下所示&#xff1a;Column(name "SOME_FIELD", updatable false, nullable false)private final String someField;當實體插入數據庫時??,這些字段存儲在數據庫中.它們無法進一步更新.對于Java編程語言,可以將這些字段視為final.使用Ecli…

python語言程序設計及醫學應用_Python語言程序設計(高等學校計算機專業規劃教材)...

第1章Python語言概述/1 1.1Python語言的發展1 1.1.1Python的起源1 1.1.2Python的發展2 1.2Python語言的特點2 1.2.1Python的特性2 1.2.2Python的缺點4 1.2.3Python與其他語言的比較5 1.3簡單的Python程序介紹5 1.4Python的程序開發工具8 1.4.1Python的版本選擇8 1.4.2Python的安…

swift 3.0 中使用 xib

文章寫于2016年9月底&#xff0c;Xcode 8&#xff0c;swift 3.0真是蛋疼&#xff0c;折騰了很長時間&#xff0c;試了網上很多教程&#xff0c;結果又莫名的可以了&#xff01; 1.方法和OC中一樣 將一個xib文件和一個ViewController類進行關聯的幾步操作&#xff1a; command &…

數字圖像處理圖像反轉的實現_使用8086微處理器反轉16位數字

數字圖像處理圖像反轉的實現Problem statement: 問題陳述&#xff1a; Write an assembly language program in 8086 microprocessor to reverse 16 bit number using 8 bits operation. 在8086微處理器中編寫匯編語言程序&#xff0c;以使用8位操作反轉16位數字。 Example: …

php猴子找大王算法,教程方法;php實現猴子選大王問題算法實例電腦技巧-琪琪詞資源網...

琪琪詞資源網-教程方法;php實現猴子選大王問題算法實例電腦技巧&#xff0c;以下是給大家帶來的教程方法;php實現猴子選大王問題算法實例&#xff0c;大家可以了解一下哦!下面為你介紹php實現猴子選大王問題算法實例。本文實例講述了php實現猴子選大王問題算法。分享給大家供大…

numpy 歸一化_NumPy 數據歸一化、可視化

僅使用 NumPy&#xff0c;下載數據&#xff0c;歸一化&#xff0c;使用 seaborn 展示數據分布。下載數據import numpy as npurl https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.datawid np.genfromtxt(url, delimiter,, dtypefloat, usecols[1])僅提取…

java虛擬機規范閱讀(三)異常

Java虛擬機里面的異常使用Throwable或其子類的實例來表示&#xff0c;拋異常的本質實際上是程序控制權的一種即時的、非局部&#xff08;Nonlocal&#xff09;的轉換——從異常拋出的地方轉換至處理異常的地方。絕大多數的異常的產生都是由于當前線程執行的某個操作所導致的&am…

puppeteer api_使用Node.js和puppeteer API從URL創建PDF文件

puppeteer apiWe will continue using Node.js and puppeteer which is a node library. As we saw in our last article, Puppeteer is a Node library developed by Google and provides a high-level API for developers. 我們將繼續使用Node.js和puppeteer(這是一個節點庫)…

python線程同步鎖_[python] 線程間同步之Lock RLock

為什么需要同步 同樣舉之前的例子&#xff0c;兩個線程分別對同一個全局變量進行加減&#xff0c;得不到預期結果&#xff0c;代碼如下&#xff1a; total 0 def add(): global total for i in range(1000000): total 1 def desc(): global total for i in range(1000000): t…

servlet的由來

2019獨角獸企業重金招聘Python工程師標準>>> 動靜態網頁技術 首先說下訪問網頁的大概過程&#xff1a; 你在瀏覽器中輸入網址&#xff0c;按下enter鍵&#xff0c;此時瀏覽器代你做了很多事&#xff0c;簡要說為&#xff1a;將你輸入的這個網址作為目的地參數&#…

php header 文件大小,php獲取遠程文件大小及信息的函數(head_php

php獲取遠程文件大小及信息的函數(header頭信息獲取)阿里西西Alixixi.com開發團隊在做一個客戶系統時&#xff0c;需要做遠程下載的功能&#xff0c;并實時顯示進度條效果。所以&#xff0c;需要預先讀取遠程文件的大小信息&#xff0c;然后做為實時下載進度條的參數。功能函數…

Java ObjectInputStream readUnsignedShort()方法(帶示例)

ObjectInputStream類readUnsignedShort()方法 (ObjectInputStream Class readUnsignedShort() method) readUnsignedShort() method is available in java.io package. readUnsignedShort()方法在java.io包中可用。 readUnsignedShort() method is used to read 2 bytes (i.e. …

python中info的用法_Python pandas.DataFrame.info函數方法的使用

DataFrame.info(self, verboseNone, bufNone, max_colsNone, memory_usageNone, null_countsNone) [source] 打印DataFrame的簡要摘要。 此方法顯示有關DataFrame的信息&#xff0c;包括索引dtype和列dtype&#xff0c;非空值和內存使用情況。 參數&#xff1a;verbose &#x…

第四次作業 孫保平034 李路平029

用C編寫一個學生成績管理系統 1、可以實現以下功能&#xff1a; cout<<"〓〓〓〓〓〓〓〓〓★ ☆ 1.增加學生成績 ☆ ★〓〓〓〓〓〓〓〓〓"<<endl; 2、用鏈表存儲信息 * 程序頭部的注釋結束 3、約定的規范&#xff1a; 1界面設計簡介&#xff0c;人性化…

php serialize error at offset,PHP Notice: unserialize(): Error at offset XX of XX bytes

之前同事在本地開發的時候&#xff0c;出現一個錯誤&#xff0c;如下圖所示&#xff1a;字面意思就是反序列化錯誤&#xff0c;由此bug引申出來序列化和反序列化得應用&#xff0c;以及php array當key為string類型的數字值時&#xff0c;會發生什么情形。先來看序列化$str [1 …

Java ClassLoader setClassAssertionStatus()方法與示例

ClassLoader類setClassAssertionStatus()方法 (ClassLoader Class setClassAssertionStatus() method) setClassAssertionStatus() method is available in java.lang package. setClassAssertionStatus()方法在java.lang包中可用。 setClassAssertionStatus() method is used …

python怎么變各種顏色_python – 如何淡化顏色

有很多方法可以做到這一點.您如何選擇這取決于您是否重視速度和簡單性或感知均勻性.如果你需要它是真正統一的,你需要用顏色配置文件定義RGB顏色,你需要配置文件的原色,這樣你就可以轉換為XYZ,然后轉換到LAB,你可以操作L通道. 大多數情況下,您不需要這樣做,而是可以使用像Photo…

informatica中元數據管理

摘自&#xff1a; http://blog.itpub.net/28690368/viewspace-766528/ informaica是一個很強大的ETL工具&#xff0c;WORKFLOW MANAGER負責對ETL調度流程進行設計與管理和執行&#xff0c;informatica在資料庫中提供以下表來存儲調動流程的相關信息&#xff0c;以便WORKFLOW …

yii+php+當前目錄,Yii應用的目錄結構和入口腳本

以下是一個通過高級模版安裝后典型的Yii應用的目錄結構&#xff1a;~~~.├── backend├── common├── console├── environments├── frontend├── nbproject├── tests├── vendor├── composer.json├── composer.lock├── init├── init.bat├── …

8086 尋址方式_8086微處理器的不同尋址模式

8086 尋址方式Introduction: 介紹&#xff1a; Addressing mode tells us what is the type of the operand and the way they are accessed from the memory for execution of an instruction and how to fetch particular instruction from the memory. There are mainly 8 …