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.mzph.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 …